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

Function buildSafeBase

packages/next/src/compiled/source-map08/source-map.js:2577–2598  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

2575}
2576
2577function buildSafeBase(str) {
2578 const maxDotParts = str.split("..").length - 1;
2579
2580 // If we used a segment that also existed in `str`, then we would be unable
2581 // to compute relative paths. For example, if `segment` were just "a":
2582 //
2583 // const url = "../../a/"
2584 // const base = buildSafeBase(url); // http://host/a/a/
2585 // const joined = "http://host/a/";
2586 // const result = relative(base, joined);
2587 //
2588 // Expected: "../../a/";
2589 // Actual: "a/"
2590 //
2591 const segment = buildUniqueSegment("p", str);
2592
2593 let base = `${PROTOCOL_AND_HOST}/`;
2594 for (let i = 0; i < maxDotParts; i++) {
2595 base += `${segment}/`;
2596 }
2597 return base;
2598}
2599
2600const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/;
2601function getURLType(url) {

Callers 3

createSafeHandlerFunction · 0.85
joinFunction · 0.85
relativeIfPossibleFunction · 0.85

Calls 2

buildUniqueSegmentFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…