@ls-stack/utils 3.51.0 → 3.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/matchPath.cjs +2 -1
- package/dist/matchPath.js +2 -1
- package/package.json +1 -1
package/dist/matchPath.cjs
CHANGED
|
@@ -58,12 +58,13 @@ function matchPath(pattern, pathname) {
|
|
|
58
58
|
if (typeof pattern === "string") {
|
|
59
59
|
pattern = { path: pattern, caseSensitive: false, end: true };
|
|
60
60
|
}
|
|
61
|
+
const normalizedPathname = pathname === "" ? "" : pathname.replace(/^\/*/, "/");
|
|
61
62
|
const [matcher, compiledParams] = compilePath(
|
|
62
63
|
pattern.path,
|
|
63
64
|
pattern.caseSensitive,
|
|
64
65
|
pattern.end
|
|
65
66
|
);
|
|
66
|
-
const match =
|
|
67
|
+
const match = normalizedPathname.match(matcher);
|
|
67
68
|
if (!match) return null;
|
|
68
69
|
const matchedPathname = match[0];
|
|
69
70
|
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
package/dist/matchPath.js
CHANGED
|
@@ -12,12 +12,13 @@ function matchPath(pattern, pathname) {
|
|
|
12
12
|
if (typeof pattern === "string") {
|
|
13
13
|
pattern = { path: pattern, caseSensitive: false, end: true };
|
|
14
14
|
}
|
|
15
|
+
const normalizedPathname = pathname === "" ? "" : pathname.replace(/^\/*/, "/");
|
|
15
16
|
const [matcher, compiledParams] = compilePath(
|
|
16
17
|
pattern.path,
|
|
17
18
|
pattern.caseSensitive,
|
|
18
19
|
pattern.end
|
|
19
20
|
);
|
|
20
|
-
const match =
|
|
21
|
+
const match = normalizedPathname.match(matcher);
|
|
21
22
|
if (!match) return null;
|
|
22
23
|
const matchedPathname = match[0];
|
|
23
24
|
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|