Skip to content

Commit

Permalink
fix(Router.SearchParam): fixed toHref
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDoge committed Nov 10, 2024
1 parent 1be937c commit e848608
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions project/app/src/lib/router/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ export namespace Router {
}

public toHref(value: T | (string & {}) | null) {
return hashSignal.derive(() => {
const searchParamsValue = new URLSearchParams(searchParams.val);
return hashSignal.derive((hash) => {
const pathname = getPathname(hash);
const searchParams = new URLSearchParams(getSearch(hash) ?? "");
if (value === null) {
searchParamsValue.delete(this.name);
searchParams.delete(this.name);
} else {
searchParamsValue.set(this.name, value);
searchParams.set(this.name, value);
}

const href = hrefFrom(pathname.val, searchParamsValue);
const href = hrefFrom(pathname, searchParams);
return href;
});
}
Expand Down

0 comments on commit e848608

Please sign in to comment.