MCPcopy Index your code
hub / github.com/mozilla/source-map / join

Function join

lib/util.js:325–359  ·  view source on GitHub ↗

* Joins two paths/URLs. * * All returned URLs will be normalized. * * @param aRoot The root path or URL. Assumed to reference a directory. * @param aPath The path or URL to be joined with the root. * @return A joined and normalized URL value.

(aRoot, aPath)

Source from the content-addressed store, hash-verified

323 * @return A joined and normalized URL value.
324 */
325function join(aRoot, aPath) {
326 const pathType = getURLType(aPath);
327 const rootType = getURLType(aRoot);
328
329 aRoot = ensureDirectory(aRoot);
330
331 if (pathType === "absolute") {
332 return withBase(aPath, undefined);
333 }
334 if (rootType === "absolute") {
335 return withBase(aPath, aRoot);
336 }
337
338 if (pathType === "scheme-relative") {
339 return normalize(aPath);
340 }
341 if (rootType === "scheme-relative") {
342 return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
343 PROTOCOL.length
344 );
345 }
346
347 if (pathType === "path-absolute") {
348 return normalize(aPath);
349 }
350 if (rootType === "path-absolute") {
351 return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(
352 PROTOCOL_AND_HOST.length
353 );
354 }
355
356 const base = buildSafeBase(aPath + aRoot);
357 const newPath = withBase(aPath, withBase(aRoot, base));
358 return computeRelativeURL(base, newPath);
359}
360exports.join = join;
361
362/**

Callers 1

computeSourceURLFunction · 0.85

Calls 4

getURLTypeFunction · 0.85
withBaseFunction · 0.85
buildSafeBaseFunction · 0.85
computeRelativeURLFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…