@rangojs/router 0.0.0-experimental.61 → 0.0.0-experimental.62
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/vite/index.js
CHANGED
|
@@ -1745,7 +1745,7 @@ import { resolve } from "node:path";
|
|
|
1745
1745
|
// package.json
|
|
1746
1746
|
var package_default = {
|
|
1747
1747
|
name: "@rangojs/router",
|
|
1748
|
-
version: "0.0.0-experimental.
|
|
1748
|
+
version: "0.0.0-experimental.62",
|
|
1749
1749
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1750
1750
|
keywords: [
|
|
1751
1751
|
"react",
|
|
@@ -3470,7 +3470,9 @@ function substituteRouteParams(pattern, params, encode = encodeURIComponent) {
|
|
|
3470
3470
|
return "";
|
|
3471
3471
|
});
|
|
3472
3472
|
if (hadOmittedOptional) {
|
|
3473
|
+
const hadTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
|
|
3473
3474
|
result = result.replace(/\/\/+/g, "/").replace(/\/+$/, "") || "/";
|
|
3475
|
+
if (hadTrailingSlash && !result.endsWith("/")) result += "/";
|
|
3474
3476
|
}
|
|
3475
3477
|
return result;
|
|
3476
3478
|
}
|
package/package.json
CHANGED
package/src/reverse.ts
CHANGED
|
@@ -332,7 +332,9 @@ export function createReverse<TRoutes extends Record<string, string>>(
|
|
|
332
332
|
// Clean up slashes only when an optional param was actually omitted,
|
|
333
333
|
// so intentional trailing-slash patterns like "/blog/" are preserved.
|
|
334
334
|
if (hadOmittedOptional) {
|
|
335
|
+
const hadTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
|
|
335
336
|
result = result.replace(/\/\/+/g, "/").replace(/\/+$/, "") || "/";
|
|
337
|
+
if (hadTrailingSlash && !result.endsWith("/")) result += "/";
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
340
|
|
|
@@ -195,7 +195,9 @@ export function createReverseFunction(
|
|
|
195
195
|
// Clean up slashes only when an optional param was actually omitted,
|
|
196
196
|
// so intentional trailing-slash patterns like "/blog/" are preserved.
|
|
197
197
|
if (hadOmittedOptional) {
|
|
198
|
+
const hadTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
|
|
198
199
|
result = result.replace(/\/\/+/g, "/").replace(/\/+$/, "") || "/";
|
|
200
|
+
if (hadTrailingSlash && !result.endsWith("/")) result += "/";
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
|
|
@@ -59,7 +59,9 @@ export function substituteRouteParams(
|
|
|
59
59
|
|
|
60
60
|
// Clean up slashes from omitted optional segments
|
|
61
61
|
if (hadOmittedOptional) {
|
|
62
|
+
const hadTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
|
|
62
63
|
result = result.replace(/\/\/+/g, "/").replace(/\/+$/, "") || "/";
|
|
64
|
+
if (hadTrailingSlash && !result.endsWith("/")) result += "/";
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
return result;
|