(str)
| 2575 | } |
| 2576 | |
| 2577 | function 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 | |
| 2600 | const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/; |
| 2601 | function getURLType(url) { |
no test coverage detected
searching dependent graphs…