Skip to content

Commit b213ad3

Browse files
author
Simon he
committed
chore: add getUrlParam
1 parent c002db2 commit b213ad3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/getUrlParam.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export function getUrlParam(s?: string): Record<string, string> | undefined {
2+
s = (s || window.location.search).split('?')[1]
3+
if (!s) return
4+
return s.split('&').reduce((pre, cur) => {
5+
const [key, value] = cur.split('=')
6+
pre[key] = value
7+
return pre
8+
}, {} as Record<string, string>)
9+
10+
}

0 commit comments

Comments
 (0)