@fibery/url-utils 2.3.3 → 2.3.5
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/lib/parse-page-location.js +5 -3
- package/lib/routes.d.ts +3 -1
- package/lib/routes.js +9 -10
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ORDERED_AUX_ROUTES, ORDERED_PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP } from "./routes.js";
|
|
1
|
+
import { ORDERED_AUX_ROUTES, ORDERED_PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, isNonSpaPath } from "./routes.js";
|
|
2
2
|
import { matchPath } from "react-router-dom";
|
|
3
3
|
//#region src/parse-page-location.ts
|
|
4
4
|
const decodeDashesToSpaces = (str = "") => str.replace(/–/g, " ");
|
|
@@ -21,9 +21,11 @@ function safeDecodeURIComponent(maybeEncodedPath) {
|
|
|
21
21
|
}
|
|
22
22
|
function findPageMatch(maybeEncodedPath) {
|
|
23
23
|
const path = safeDecodeURIComponent(maybeEncodedPath);
|
|
24
|
-
|
|
24
|
+
if (isNonSpaPath(path)) return null;
|
|
25
|
+
const dashDecodedPath = decodeDashesToSpaces(path);
|
|
26
|
+
const processedPath = decodeUnderscoresToSpaces(dashDecodedPath);
|
|
25
27
|
return findTruthy(ORDERED_PAGE_ROUTES, ([page, route]) => {
|
|
26
|
-
const match = matchPath(route
|
|
28
|
+
const match = matchPath(ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP[route] ? dashDecodedPath : processedPath, {
|
|
27
29
|
path: route,
|
|
28
30
|
exact: true
|
|
29
31
|
});
|
package/lib/routes.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ declare const personalIntegrationSettingPage = "/fibery/settings/:subsection(per
|
|
|
23
23
|
declare const oauthApplicationSettingPage = "/fibery/settings/:subsection(oauth-applications)/:applicationId";
|
|
24
24
|
declare const typeAccessTemplateSettingPage = "/fibery/settings/:subsection(database-access-templates)/:templateId";
|
|
25
25
|
declare const isSettingsPage: (page?: string) => boolean;
|
|
26
|
+
declare const NON_SPA_PATH_PREFIXES: string[];
|
|
27
|
+
declare const isNonSpaPath: (path: string) => boolean;
|
|
26
28
|
declare const ORDERED_PAGE_ROUTES: Array<[string, string]>;
|
|
27
29
|
declare const PAGE_ROUTES: import("lodash").Dictionary<string>;
|
|
28
30
|
declare const ORDERED_COMMON_AUX_ROUTES: Array<[string, string]>;
|
|
@@ -36,4 +38,4 @@ declare const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP: {
|
|
|
36
38
|
[k: string]: boolean;
|
|
37
39
|
};
|
|
38
40
|
//#endregion
|
|
39
|
-
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isSettingsPage, oauthApplicationSettingPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
|
41
|
+
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, NON_SPA_PATH_PREFIXES, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isNonSpaPath, isSettingsPage, oauthApplicationSettingPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
package/lib/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeRegExpChar } from "./locator-utils.js";
|
|
2
|
-
import { formsUrlPrefix, publicUrlPrefix } from "./url-constants.js";
|
|
2
|
+
import { appsUrlPrefix, formsUrlPrefix, publicAppsUrlPrefix, publicUrlPrefix } from "./url-constants.js";
|
|
3
3
|
import fromPairs from "lodash/fromPairs.js";
|
|
4
4
|
//#region src/routes.ts
|
|
5
5
|
const titleWithPublicIdLocatorPattern = `[^/=]+?-\\d+`;
|
|
@@ -106,7 +106,10 @@ const orderedRoutes = [
|
|
|
106
106
|
[":page/app-root", `/:appNamespace`],
|
|
107
107
|
[":page/root", `/`]
|
|
108
108
|
];
|
|
109
|
-
const
|
|
109
|
+
const NON_SPA_PATH_PREFIXES = [appsUrlPrefix, publicAppsUrlPrefix];
|
|
110
|
+
const isNonSpaPath = (path) => NON_SPA_PATH_PREFIXES.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
|
|
111
|
+
const withPublicPrefix = (route) => `${publicUrlPrefix}${route === "/" ? "" : route}`;
|
|
112
|
+
const ORDERED_PAGE_ROUTES = orderedRoutes.map(([page, route]) => [page, withPublicPrefix(route)]).concat(orderedRoutes);
|
|
110
113
|
const PAGE_ROUTES = fromPairs(ORDERED_PAGE_ROUTES);
|
|
111
114
|
const ORDERED_COMMON_AUX_ROUTES = [
|
|
112
115
|
[":aux/no-panel-support", `no-panel/:type`],
|
|
@@ -132,7 +135,6 @@ const ORDERED_COMMON_AUX_ROUTES = [
|
|
|
132
135
|
[":aux/gallery-app", `gallery/:auxAppNamespace`],
|
|
133
136
|
[":aux/search", `search/:id`],
|
|
134
137
|
[":aux/shared-with-me", `shared-with-me`],
|
|
135
|
-
[":aux/import", `import`],
|
|
136
138
|
[":aux/app-export", `app-export/:auxAppNamespace/share`],
|
|
137
139
|
[":aux/install-integration-app", `app-sync/:auxAppNamespace`],
|
|
138
140
|
[":aux/users-invite", `invite-users`],
|
|
@@ -145,13 +147,10 @@ const ORDERED_COMMON_AUX_ROUTES = [
|
|
|
145
147
|
const ORDERED_AUX_ROUTES = [...ORDERED_COMMON_AUX_ROUTES, [":aux/view-config-raw", "config/raw"]];
|
|
146
148
|
const AUX_ROUTES = fromPairs(ORDERED_AUX_ROUTES);
|
|
147
149
|
const AUX_ROUTES_PATTERNS = ORDERED_AUX_ROUTES.map(([, pattern]) => pattern);
|
|
148
|
-
const ROUTES_WITH_PRESERVED_UNDERSCORES = [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
":aux/upgrade-to-plan"
|
|
152
|
-
];
|
|
153
|
-
const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS = ORDERED_AUX_ROUTES.filter(([route]) => ROUTES_WITH_PRESERVED_UNDERSCORES.includes(route)).map(([, pattern]) => pattern);
|
|
150
|
+
const ROUTES_WITH_PRESERVED_UNDERSCORES = [":aux/type-object-editor-for-composite-type", ":aux/object-editor-for-composite-type"];
|
|
151
|
+
const PAGE_ROUTES_WITH_PRESERVED_UNDERSCORES = [oauthApplicationSettingPage];
|
|
152
|
+
const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS = ORDERED_AUX_ROUTES.filter(([route]) => ROUTES_WITH_PRESERVED_UNDERSCORES.includes(route)).map(([, pattern]) => pattern).concat(PAGE_ROUTES_WITH_PRESERVED_UNDERSCORES.flatMap((route) => [route, withPublicPrefix(route)]));
|
|
154
153
|
const ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES.map((x) => [x, true]));
|
|
155
154
|
const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS.map((x) => [x, true]));
|
|
156
155
|
//#endregion
|
|
157
|
-
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isSettingsPage, oauthApplicationSettingPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
|
156
|
+
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, NON_SPA_PATH_PREFIXES, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isNonSpaPath, isSettingsPage, oauthApplicationSettingPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/url-utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"lodash": "4.
|
|
23
|
+
"lodash": "4.18.1",
|
|
24
24
|
"path-to-regexp": "3.0.0",
|
|
25
25
|
"react-router-dom": "5.3.4"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"lodash": "4.
|
|
28
|
+
"lodash": "4.18.1",
|
|
29
29
|
"react-router-dom": "^5.3.0"
|
|
30
30
|
}
|
|
31
31
|
}
|