@solidjs/router 0.7.0 → 0.7.1
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/README.md +1 -1
- package/dist/index.js +6 -5
- package/dist/utils.js +6 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -533,7 +533,7 @@ const [searchParams, setSearchParams] = useSearchParams();
|
|
|
533
533
|
return (
|
|
534
534
|
<div>
|
|
535
535
|
<span>Page: {searchParams.page}</span>
|
|
536
|
-
<button onClick={() => setSearchParams({ page: searchParams.page + 1 })}>Next Page</button>
|
|
536
|
+
<button onClick={() => setSearchParams({ page: (parseInt(searchParams.page) || 0) + 1 })}>Next Page</button>
|
|
537
537
|
</div>
|
|
538
538
|
);
|
|
539
539
|
```
|
package/dist/index.js
CHANGED
|
@@ -148,9 +148,9 @@ function createBeforeLeave() {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
const hasSchemeRegex = /^(?:[a-z0-9]+:)?\/\//i;
|
|
151
|
-
const trimPathRegex =
|
|
151
|
+
const trimPathRegex = /^\/+|(\/)\/+$/g;
|
|
152
152
|
function normalizePath(path, omitSlash = false) {
|
|
153
|
-
const s = path.replace(trimPathRegex, "");
|
|
153
|
+
const s = path.replace(trimPathRegex, "$1");
|
|
154
154
|
return s ? omitSlash || /^[?#]/.test(s) ? s : "/" + s : "";
|
|
155
155
|
}
|
|
156
156
|
function resolvePath(base, path, from) {
|
|
@@ -203,10 +203,11 @@ function createMatcher(path, partial, matchFilters) {
|
|
|
203
203
|
for (let i = 0; i < len; i++) {
|
|
204
204
|
const segment = segments[i];
|
|
205
205
|
const locSegment = locSegments[i];
|
|
206
|
-
const
|
|
207
|
-
|
|
206
|
+
const dynamic = segment[0] === ":";
|
|
207
|
+
const key = dynamic ? segment.slice(1) : segment;
|
|
208
|
+
if (dynamic && matchSegment(locSegment, matchFilter(key))) {
|
|
208
209
|
match.params[key] = locSegment;
|
|
209
|
-
} else if (!matchSegment(locSegment, segment)) {
|
|
210
|
+
} else if (dynamic || !matchSegment(locSegment, segment)) {
|
|
210
211
|
return null;
|
|
211
212
|
}
|
|
212
213
|
match.path += `/${locSegment}`;
|
package/dist/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createMemo, getOwner, runWithOwner } from "solid-js";
|
|
2
2
|
const hasSchemeRegex = /^(?:[a-z0-9]+:)?\/\//i;
|
|
3
|
-
const trimPathRegex =
|
|
3
|
+
const trimPathRegex = /^\/+|(\/)\/+$/g;
|
|
4
4
|
export function normalizePath(path, omitSlash = false) {
|
|
5
|
-
const s = path.replace(trimPathRegex, "");
|
|
5
|
+
const s = path.replace(trimPathRegex, "$1");
|
|
6
6
|
return s ? (omitSlash || /^[?#]/.test(s) ? s : "/" + s) : "";
|
|
7
7
|
}
|
|
8
8
|
export function resolvePath(base, path, from) {
|
|
@@ -57,11 +57,12 @@ export function createMatcher(path, partial, matchFilters) {
|
|
|
57
57
|
for (let i = 0; i < len; i++) {
|
|
58
58
|
const segment = segments[i];
|
|
59
59
|
const locSegment = locSegments[i];
|
|
60
|
-
const
|
|
61
|
-
|
|
60
|
+
const dynamic = segment[0] === ":";
|
|
61
|
+
const key = dynamic ? segment.slice(1) : segment;
|
|
62
|
+
if (dynamic && matchSegment(locSegment, matchFilter(key))) {
|
|
62
63
|
match.params[key] = locSegment;
|
|
63
64
|
}
|
|
64
|
-
else if (!matchSegment(locSegment, segment)) {
|
|
65
|
+
else if (dynamic || !matchSegment(locSegment, segment)) {
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
68
|
match.path += `/${locSegment}`;
|