Skip to content

Commit

Permalink
chore(dom): router support getQuery(key: string) + getQuery()
Browse files Browse the repository at this point in the history
  • Loading branch information
whatwewant committed Sep 4, 2023
1 parent 81d58e5 commit f6ea3f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zodash/dom",
"version": "0.1.20",
"version": "1.0.0",
"description": "DOM Utils",
"keywords": [
"zodash",
Expand Down
11 changes: 9 additions & 2 deletions packages/dom/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ export function getUrl(): string {
return window.location.href;
}

export function getQuery(): Record<string, string> {
return qs.parse(window.location.search);
export function getQuery(key: string): string;
export function getQuery(): Record<string, string>;
export function getQuery(key?: any): any {
const object = qs.parse(window.location.search);
if (key) {
return object[key];
}

return object;
}

export function getLocation() {
Expand Down

0 comments on commit f6ea3f6

Please sign in to comment.