ln-parse-query

Parse the passed in query paramenter into an object with the same key value pairs.

Usage no npm install needed!

<script type="module">
  import lnParseQuery from 'https://cdn.skypack.dev/ln-parse-query';
</script>

README

ln-parse-query

Parse a given query strning into its equivalent object.

Installing

npm install --save ln-parse-query

Using

Just load the module and call the parser.

const parser = require("ln-parse-query");

parser("hello=goodbye&foo=bar%20all%20day&novalue");
/*
* {
*   hello: "goodbye",
*   foo: "bar all day",
*   novalue: ""
* }
*/

The module removes trailing '?' or '#' so that it can be used in the browser with window.location.hash or window.location.search