@nimpl/getters 1.3.2 → 1.3.3-canary.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/get-params.js +3 -8
- package/package.json +1 -1
- package/utils.js +2 -1
package/get-params.js
CHANGED
|
@@ -12,18 +12,13 @@ const getParams = () => {
|
|
|
12
12
|
const { urlPathname, pagePath = "/" } = store;
|
|
13
13
|
const cleanUrlPathname = (0, utils_1.normalizePathname)(urlPathname);
|
|
14
14
|
const cleanPagePath = (0, utils_1.normalizePagePath)(pagePath);
|
|
15
|
-
const pagePathParts = cleanPagePath
|
|
16
|
-
.split("/")
|
|
17
|
-
.slice(1)
|
|
18
|
-
.filter((part) => !part.match(/^(\([^)]+\)|\@.+)$/));
|
|
15
|
+
const pagePathParts = cleanPagePath.split("/");
|
|
19
16
|
const pagePathInterceptedParts = (0, utils_1.normalizeInterceptingRoutes)(pagePathParts);
|
|
20
|
-
const pathnameParts = cleanUrlPathname.split("/")
|
|
21
|
-
const isRootPage = cleanUrlPathname === "" && cleanPagePath === "";
|
|
17
|
+
const pathnameParts = cleanUrlPathname.split("/");
|
|
22
18
|
const isNotFoundPage = pagePath.match(/\/_not-found\/?$/);
|
|
23
19
|
const isValidCatchALl = cleanPagePath.match(/\/\[\.\.\.[^\]]+\]/) && pathnameParts.length >= pagePathInterceptedParts.length;
|
|
24
20
|
const isValidOptionalCatchALl = cleanPagePath.match(/\/\[\[\.\.\.[^\]]+\]\]/) && pathnameParts.length >= pagePathInterceptedParts.length - 1;
|
|
25
|
-
const isCorrectMatched =
|
|
26
|
-
isNotFoundPage ||
|
|
21
|
+
const isCorrectMatched = isNotFoundPage ||
|
|
27
22
|
pagePathInterceptedParts.length === pathnameParts.length ||
|
|
28
23
|
isValidCatchALl ||
|
|
29
24
|
isValidOptionalCatchALl;
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -11,7 +11,8 @@ exports.normalizePathname = normalizePathname;
|
|
|
11
11
|
const normalizePagePath = (pagePath) => {
|
|
12
12
|
const cleanPagePath = pagePath && new URL(pagePath, "http://n").pathname;
|
|
13
13
|
const pagePathWithoutFileType = cleanPagePath?.replace(/(\/page|\/_not-found)$/, "");
|
|
14
|
-
|
|
14
|
+
const pagePathWithoutGroups = pagePathWithoutFileType.replace(/\/(\([^)]+\)|\@.+)/g, "");
|
|
15
|
+
return pagePathWithoutGroups || "/";
|
|
15
16
|
};
|
|
16
17
|
exports.normalizePagePath = normalizePagePath;
|
|
17
18
|
const parseSegments = (pagePathParts, pathnameParts) => {
|