MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / resolveRelative

Function resolveRelative

src/client/sandbox.mjs:427–436  ·  view source on GitHub ↗
(base, path)

Source from the content-addressed store, hash-verified

425}
426
427function resolveRelative(base, path) {
428 if (!/\.\.?\//.test(path)) return path
429 base = base.replace(/[^\/]+$/, "")
430 let m
431 while (m = /^\.(\.)?\//.exec(path)) {
432 if (m[1]) base = base.replace(/\/[^\/]+\/$/, "/")
433 path = path.slice(m[0].length)
434 }
435 return base + path
436}
437
438class Cached {
439 constructor(mapping) {

Callers 1

evalModuleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected