@jsenv/url-meta
Advanced tools
Comparing version 7.1.0 to 8.0.0
{ | ||
"name": "@jsenv/url-meta", | ||
"version": "7.1.0", | ||
"version": "8.0.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -130,6 +130,10 @@ /* | ||
consumePattern(2) // consumes "**" | ||
let skipAllowed = true | ||
if (remainingPattern[0] === "/") { | ||
consumePattern(1) // consumes "/" | ||
if (!remainingString.includes("/")) { | ||
skipAllowed = false | ||
} | ||
} | ||
// pattern ending with ** always match remaining string | ||
// pattern ending with "**" or "**/" always match remaining string | ||
if (remainingPattern === "") { | ||
@@ -139,12 +143,14 @@ consumeRemainingString() | ||
} | ||
const skipResult = skipUntilMatch({ | ||
pattern: remainingPattern, | ||
string: remainingString, | ||
canSkipSlash: true, | ||
}) | ||
groups.push(...skipResult.groups) | ||
consumePattern(skipResult.patternIndex) | ||
consumeRemainingString() | ||
restoreIndexes = false | ||
return skipResult.matched | ||
if (skipAllowed) { | ||
const skipResult = skipUntilMatch({ | ||
pattern: remainingPattern, | ||
string: remainingString, | ||
canSkipSlash: true, | ||
}) | ||
groups.push(...skipResult.groups) | ||
consumePattern(skipResult.patternIndex) | ||
consumeRemainingString() | ||
restoreIndexes = false | ||
return skipResult.matched | ||
} | ||
} | ||
@@ -199,3 +205,3 @@ if (remainingPattern[0] === "*") { | ||
let remainingString = string | ||
let longestMatchRange = null | ||
let longestAttemptRange = null | ||
const tryToMatch = () => { | ||
@@ -217,16 +223,24 @@ const matchAttempt = applyMatching(pattern, remainingString) | ||
} | ||
const matchAttemptIndex = matchAttempt.index | ||
const matchRange = { | ||
const attemptIndex = matchAttempt.index | ||
const attemptRange = { | ||
patternIndex: matchAttempt.patternIndex, | ||
index, | ||
length: matchAttemptIndex, | ||
length: attemptIndex, | ||
groups: matchAttempt.groups, | ||
} | ||
if (!longestMatchRange || longestMatchRange.length < matchRange.length) { | ||
longestMatchRange = matchRange | ||
if ( | ||
!longestAttemptRange || | ||
longestAttemptRange.length < attemptRange.length | ||
) { | ||
longestAttemptRange = attemptRange | ||
} | ||
const nextIndex = matchAttemptIndex + 1 | ||
const canSkip = | ||
nextIndex < remainingString.length && | ||
(canSkipSlash || remainingString[0] !== "/") | ||
const nextIndex = attemptIndex + 1 | ||
let canSkip | ||
if (nextIndex >= remainingString.length) { | ||
canSkip = false | ||
} else if (remainingString[0] === "/" && !canSkipSlash) { | ||
canSkip = false | ||
} else { | ||
canSkip = true | ||
} | ||
if (canSkip) { | ||
@@ -240,7 +254,7 @@ // search against the next unattempted string | ||
matched: false, | ||
patternIndex: longestMatchRange.patternIndex, | ||
index: longestMatchRange.index + longestMatchRange.length, | ||
groups: longestMatchRange.groups, | ||
patternIndex: longestAttemptRange.patternIndex, | ||
index: longestAttemptRange.index + longestAttemptRange.length, | ||
groups: longestAttemptRange.groups, | ||
group: { | ||
string: string.slice(0, longestMatchRange.index), | ||
string: string.slice(0, longestAttemptRange.index), | ||
}, | ||
@@ -247,0 +261,0 @@ } |
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
17778
470