MCPcopy Create free account
hub / github.com/Effect-TS/effect / toFileUrl

Function toFileUrl

packages/effect/src/Path.ts:501–514  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

499const CHAR_FORWARD_SLASH = 47
500
501function toFileUrl(filepath: string) {
502 const outURL = new URL("file://")
503 let resolved = resolve(filepath)
504 // path.resolve strips trailing slashes so we must add them back
505 const filePathLast = filepath.charCodeAt(filepath.length - 1)
506 if (
507 (filePathLast === CHAR_FORWARD_SLASH) &&
508 resolved[resolved.length - 1] !== "/"
509 ) {
510 resolved += "/"
511 }
512 outURL.pathname = encodePathChars(resolved)
513 return Effect.succeed(outURL)
514}
515
516const percentRegExp = /%/g
517const backslashRegExp = /\\/g

Callers

nothing calls this directly

Calls 3

encodePathCharsFunction · 0.85
resolveFunction · 0.70
succeedMethod · 0.45

Tested by

no test coverage detected