const convertQueryToMap = (query) => {
const arrWithoutAmpersand = query.split("&")
return arrWithoutAmpersand.reduce((initialValue, string) => {
const [stringPath, stringValue] = string.split("=")
let object = initialValue
stringPath.split(".").forEach((key, i, arr) => {
if (!object[key]) {
if (typeof stringValue === "string" && !stringValue.length || stringValue === undefined) {
return
} else {
object[key] = i === arr.length - 1 ? decodeURIComponent(stringValue) : {}
}
}
object = object[key]
})
return initialValue
}, {})
}