(str)
| 211 | } |
| 212 | |
| 213 | function buildSafeBase(str) { |
| 214 | const maxDotParts = str.split("..").length - 1; |
| 215 | |
| 216 | // If we used a segment that also existed in `str`, then we would be unable |
| 217 | // to compute relative paths. For example, if `segment` were just "a": |
| 218 | // |
| 219 | // const url = "../../a/" |
| 220 | // const base = buildSafeBase(url); // http://host/a/a/ |
| 221 | // const joined = "http://host/a/"; |
| 222 | // const result = relative(base, joined); |
| 223 | // |
| 224 | // Expected: "../../a/"; |
| 225 | // Actual: "a/" |
| 226 | // |
| 227 | const segment = buildUniqueSegment("p", str); |
| 228 | |
| 229 | let base = `${PROTOCOL_AND_HOST}/`; |
| 230 | for (let i = 0; i < maxDotParts; i++) { |
| 231 | base += `${segment}/`; |
| 232 | } |
| 233 | return base; |
| 234 | } |
| 235 | |
| 236 | const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/; |
| 237 | function getURLType(url) { |
no test coverage detected
searching dependent graphs…