litestar-vite-plugin 0.6.5 → 0.6.6
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/inertia-helpers/index.js +5 -2
- package/package.json +1 -1
package/inertia-helpers/index.js
CHANGED
|
@@ -63,6 +63,9 @@ export function getRelativeUrlPath(url) {
|
|
|
63
63
|
return url;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
function routePatternToRegex(pattern) {
|
|
67
|
+
return new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
|
|
68
|
+
}
|
|
66
69
|
export function toRoute(url) {
|
|
67
70
|
url = getRelativeUrlPath(url);
|
|
68
71
|
url = url === '/' ? url : url.replace(/\/$/, '');
|
|
@@ -94,7 +97,7 @@ export function currentRoute() {
|
|
|
94
97
|
export function isRoute(url, routeName) {
|
|
95
98
|
url = getRelativeUrlPath(url);
|
|
96
99
|
url = url === '/' ? url : url.replace(/\/$/, '');
|
|
97
|
-
const routeNameRegex =
|
|
100
|
+
const routeNameRegex = routePatternToRegex(routeName);
|
|
98
101
|
for (const routeName in routes) {
|
|
99
102
|
if (routeNameRegex.test(routeName)) {
|
|
100
103
|
const routePattern = routes[routeName];
|
|
@@ -123,7 +126,7 @@ export function isCurrentRoute(routeName) {
|
|
|
123
126
|
console.error("Could not match current window location to a named route.");
|
|
124
127
|
return false;
|
|
125
128
|
}
|
|
126
|
-
const routeNameRegex =
|
|
129
|
+
const routeNameRegex = routePatternToRegex(routeName);
|
|
127
130
|
return routeNameRegex.test(currentRouteName);
|
|
128
131
|
}
|
|
129
132
|
globalThis.routes = globalThis.routes || {};
|