Skip to content

Instantly share code, notes, and snippets.

View Dinir's full-sized avatar
🦽
Lost

Dinir Nertan Dinir

🦽
Lost
View GitHub Profile
@Dinir
Dinir / parse-query-parameters-into-a-map.js
Last active November 27, 2021 12:06 — forked from MatthewDaniels/parse-query-parameters-into-a-map.js
Parses a query parameter string into a javascript map. This script deals with multiple values by placing them into an array.
/**
* Get a query map based on a query string.
*
* The function will populate a map variable with key value pairs of the parameters.
*
* If there is more than one of the same key, the function will populate an array in the map with the multiple values within it.
*
* Forked from {@link https://gist.github.com/MatthewDaniels/388fa1e0c02613f103f00a504ed58c55 MatthewDaniels/parse-query-parameters-into-a-map.js}.
*
* @param {?string} [query=window.location.search] The query string - the question mark is optional