Use .entries only if we're in a modern browser (#934)

This commit is contained in:
jascha ehrenreich 2020-03-09 14:34:26 +01:00 committed by GitHub
parent 48acd86258
commit b8cc0faa8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -1,11 +1,11 @@
export const entries = (params) => {
if (typeof Object.fromEntries === 'function') {
return Object.fromEntries(params)
return Object.fromEntries(params.entries())
}
const obj = {}
params.forEach(([key, val]) => {
params.forEach((val, key) => {
obj[key] = val
})
@ -23,6 +23,6 @@ export const getPathInfo = (path) => {
return {
path: withoutTrailingSlash,
query: search,
queryParams: entries(searchParams.entries())
queryParams: entries(searchParams)
}
}