Roll own Object.fromEntries; fix #919
This commit is contained in:
parent
afedff6649
commit
b164243235
|
@ -1,3 +1,17 @@
|
|||
export const entries = (params) => {
|
||||
if (typeof Object.fromEntries === 'function') {
|
||||
return Object.fromEntries(params)
|
||||
}
|
||||
|
||||
const obj = {}
|
||||
|
||||
params.forEach(([key, val]) => {
|
||||
obj[key] = val
|
||||
})
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
export const getPathInfo = (path) => {
|
||||
const url = new URL(path, 'http://localhost')
|
||||
|
@ -9,6 +23,6 @@ export const getPathInfo = (path) => {
|
|||
return {
|
||||
path: withoutTrailingSlash,
|
||||
query: search,
|
||||
queryParams: Object.fromEntries(searchParams.entries())
|
||||
queryParams: entries(searchParams.entries())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue