MCPcopy
hub / github.com/vercel/next.js / join

Function join

packages/next/src/compiled/source-map08/source-map.js:2689–2719  ·  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

2687 * @return A joined and normalized URL value.
2688 */
2689function join(aRoot, aPath) {
2690 const pathType = getURLType(aPath);
2691 const rootType = getURLType(aRoot);
2692
2693 aRoot = ensureDirectory(aRoot);
2694
2695 if (pathType === "absolute") {
2696 return withBase(aPath, undefined);
2697 }
2698 if (rootType === "absolute") {
2699 return withBase(aPath, aRoot);
2700 }
2701
2702 if (pathType === "scheme-relative") {
2703 return normalize(aPath);
2704 }
2705 if (rootType === "scheme-relative") {
2706 return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL.length);
2707 }
2708
2709 if (pathType === "path-absolute") {
2710 return normalize(aPath);
2711 }
2712 if (rootType === "path-absolute") {
2713 return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);
2714 }
2715
2716 const base = buildSafeBase(aPath + aRoot);
2717 const newPath = withBase(aPath, withBase(aRoot, base));
2718 return computeRelativeURL(base, newPath);
2719}
2720exports.join = join;
2721
2722/**

Callers 1

computeSourceURLFunction · 0.70

Calls 6

withBaseFunction · 0.85
buildSafeBaseFunction · 0.85
computeRelativeURLFunction · 0.85
getURLTypeFunction · 0.70
normalizeFunction · 0.50
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…