Skip to content

Commit f8aaf16

Browse files
committed
make url transform consistent
1 parent 86c3b1f commit f8aaf16

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.changeset/grumpy-chairs-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
make url transform consistent

src/routers/Router.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export function Router(props: RouterProps): JSX.Element {
1313
const getSource = () => {
1414
const url = window.location.pathname.replace(/^\/+/, "/") + window.location.search;
1515
return {
16-
value: props.transformUrl ? props.transformUrl(url) + window.location.hash : url + window.location.hash,
17-
rawPath: url,
16+
value: url + window.location.hash,
1817
state: window.history.state
1918
}
2019
};

src/routers/StaticRouter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ export type StaticRouterProps = BaseRouterProps & { url?: string };
1111

1212
export function StaticRouter(props: StaticRouterProps): JSX.Element {
1313
let e;
14-
const url = props.url || ((e = getRequestEvent()) && getPath(e.request.url)) || ""
1514
const obj = {
16-
value: props.transformUrl ? props.transformUrl(url) : url,
17-
rawPath: url,
15+
value: props.url || ((e = getRequestEvent()) && getPath(e.request.url)) || "",
1816
};
1917
return createRouterComponent({
2018
signal: [() => obj, next => Object.assign(obj, next)]

src/routing.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export function createRouterContext(
401401
return;
402402
}
403403

404-
const queryOnly = to[0] === "?";
404+
const queryOnly = !to || to[0] === "?";
405405
const {
406406
replace,
407407
resolve,
@@ -414,9 +414,10 @@ export function createRouterContext(
414414
...options
415415
};
416416

417+
let s: string;
417418
const resolvedTo = resolve
418419
? route.resolvePath(to)
419-
: resolvePath((queryOnly && source().rawPath) || "", to);
420+
: resolvePath((queryOnly && (s = source().value) && s.split("?")[0]) || "", to);
420421

421422
if (resolvedTo === undefined) {
422423
throw new Error(`Path '${to}' is not a routable path`);

0 commit comments

Comments
 (0)