-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mebtte
committed
Apr 30, 2024
1 parent
966a3fd
commit 1dd6756
Showing
2 changed files
with
4 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
function parseSearch<Keys extends string>(search?: string) { | ||
const query: { | ||
function parseSearch<Keys extends string>(search: string) { | ||
return Object.fromEntries(new URLSearchParams(search).entries()) as { | ||
[key in Keys]?: string; | ||
} = {}; | ||
if (search) { | ||
const s = search.replace(/\?/g, ''); | ||
s.split('&').forEach((kv) => { | ||
const [key, value] = kv.split('='); | ||
query[key] = decodeURIComponent(value); | ||
}); | ||
} | ||
return query; | ||
}; | ||
} | ||
|
||
export default parseSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters