@jsenv/url-meta
Advanced tools
Comparing version 8.0.0 to 8.1.0
{ | ||
"name": "@jsenv/url-meta", | ||
"version": "8.0.0", | ||
"version": "8.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -133,2 +133,5 @@ /* | ||
consumePattern(1) // consumes "/" | ||
// when remainingPattern was preceeded by "**/" | ||
// and remainingString have no "/" | ||
// then skip is not allowed, a regular match will be performed | ||
if (!remainingString.includes("/")) { | ||
@@ -138,3 +141,3 @@ skipAllowed = false | ||
} | ||
// pattern ending with "**" or "**/" always match remaining string | ||
// pattern ending with "**" or "**/" match remaining string | ||
if (remainingPattern === "") { | ||
@@ -160,3 +163,3 @@ consumeRemainingString() | ||
if (remainingPattern === "") { | ||
// matches everything except '/' | ||
// matches everything except "/" | ||
const slashIndex = remainingString.indexOf("/") | ||
@@ -207,2 +210,16 @@ if (slashIndex === -1) { | ||
let longestAttemptRange = null | ||
let isLastAttempt = false | ||
const failure = () => { | ||
return { | ||
matched: false, | ||
patternIndex: longestAttemptRange.patternIndex, | ||
index: longestAttemptRange.index + longestAttemptRange.length, | ||
groups: longestAttemptRange.groups, | ||
group: { | ||
string: string.slice(0, longestAttemptRange.index), | ||
}, | ||
} | ||
} | ||
const tryToMatch = () => { | ||
@@ -237,28 +254,24 @@ const matchAttempt = applyMatching(pattern, remainingString) | ||
} | ||
if (isLastAttempt) { | ||
return failure() | ||
} | ||
const nextIndex = attemptIndex + 1 | ||
let canSkip | ||
if (nextIndex >= remainingString.length) { | ||
canSkip = false | ||
} else if (remainingString[0] === "/" && !canSkipSlash) { | ||
canSkip = false | ||
} else { | ||
canSkip = true | ||
return failure() | ||
} | ||
if (canSkip) { | ||
// search against the next unattempted string | ||
index += nextIndex | ||
remainingString = remainingString.slice(nextIndex) | ||
return tryToMatch() | ||
if (remainingString[0] === "/") { | ||
if (!canSkipSlash) { | ||
return failure() | ||
} | ||
// when it's the last slash, the next attempt is the last | ||
if (remainingString.indexOf("/", 1) === -1) { | ||
isLastAttempt = true | ||
} | ||
} | ||
return { | ||
matched: false, | ||
patternIndex: longestAttemptRange.patternIndex, | ||
index: longestAttemptRange.index + longestAttemptRange.length, | ||
groups: longestAttemptRange.groups, | ||
group: { | ||
string: string.slice(0, longestAttemptRange.index), | ||
}, | ||
} | ||
// search against the next unattempted string | ||
index += nextIndex | ||
remainingString = remainingString.slice(nextIndex) | ||
return tryToMatch() | ||
} | ||
return tryToMatch() | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18146
481