bun-plugin-stx 0.2.148 → 0.2.150
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.
|
@@ -75,21 +75,35 @@ function filePathToPattern(filePath, pagesDir) {
|
|
|
75
75
|
}
|
|
76
76
|
function patternToRegex(pattern) {
|
|
77
77
|
const params = [];
|
|
78
|
-
let regexStr =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
let regexStr = "";
|
|
79
|
+
let i = 0;
|
|
80
|
+
while (i < pattern.length) {
|
|
81
|
+
const rest = pattern.slice(i);
|
|
82
|
+
const optional = /^\/:([^/?*]+)\?/.exec(rest);
|
|
83
|
+
if (optional) {
|
|
84
|
+
params.push(optional[1]);
|
|
85
|
+
regexStr += "(?:/([^/]+))?";
|
|
86
|
+
i += optional[0].length;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const catchAll = /^:([^/?*]+)\*/.exec(rest);
|
|
90
|
+
if (catchAll) {
|
|
91
|
+
params.push(catchAll[1]);
|
|
92
|
+
regexStr += "(.+)";
|
|
93
|
+
i += catchAll[0].length;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const required = /^:([^/?*]+)/.exec(rest);
|
|
97
|
+
if (required) {
|
|
98
|
+
params.push(required[1]);
|
|
99
|
+
regexStr += "([^/]+)";
|
|
100
|
+
i += required[0].length;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
regexStr += pattern[i].replace(/[.+^${}()|[\]\\*?]/g, "\\$&");
|
|
104
|
+
i += 1;
|
|
105
|
+
}
|
|
106
|
+
return { regex: new RegExp(`^${regexStr}$`), params };
|
|
93
107
|
}
|
|
94
108
|
function matchRoute(pathname, routes) {
|
|
95
109
|
const normalizedPath = pathname === "" ? "/" : pathname;
|
|
@@ -105,6 +119,10 @@ function matchRoute(pathname, routes) {
|
|
|
105
119
|
}
|
|
106
120
|
return null;
|
|
107
121
|
}
|
|
122
|
+
function bracketPathToRegex(routePath) {
|
|
123
|
+
const pattern = routePath.replace(/\[\[([^\]]+)\]\]/g, ":$1?").replace(/\[([^\]]+)\]/g, ":$1").replace(/:\.\.\.([^/]+)/g, ":$1*");
|
|
124
|
+
return patternToRegex(pattern);
|
|
125
|
+
}
|
|
108
126
|
|
|
109
127
|
// ../router/src/nested-layouts.ts
|
|
110
128
|
import fs2 from "fs";
|
|
@@ -1705,6 +1723,7 @@ export {
|
|
|
1705
1723
|
createMiddlewareContext,
|
|
1706
1724
|
createClientCookieManager,
|
|
1707
1725
|
clearMiddleware,
|
|
1726
|
+
bracketPathToRegex,
|
|
1708
1727
|
abortNavigation,
|
|
1709
1728
|
Router
|
|
1710
1729
|
};
|
package/dist/serve.js
CHANGED
|
@@ -9361,7 +9361,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9361
9361
|
pageMiddlewarePatterns.length = 0;
|
|
9362
9362
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
9363
9363
|
try {
|
|
9364
|
-
const { Router } = await import("./chunk-
|
|
9364
|
+
const { Router } = await import("./chunk-8nbccnre.js");
|
|
9365
9365
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9366
9366
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName() });
|
|
9367
9367
|
if (!options.quiet)
|
package/package.json
CHANGED