qrystr-parse-170615
Reduced version of qrystr: Takes the minimalism further for cases where you only need decoding of very simple QS.
- "very simple QS" includes treating
…&flag&…
the same as…&flag=&…
, i.e. as an empty string value. If you wanttrue
instead, use theqrystr
module.
Still too large a library? You might not need any at all: URLSearchParams are now widely supported.
Usage
from test/all.js:
var refQSmod = require('querystring'),
pqs = require('qrystr-parse-170615'),
slim = require('qrystr-parse-170615/slim');
function verify(qs) {
var ex = ((typeof qs === 'string') && refQSmod.parse(qs));
if (!ex) {
ex = qs;
qs = refQSmod.stringify(ex);
}
eq(pqs(qs), ex);
eq(slim(qs), ex);
}
verify({ hello: 'world', '23': '42', 'úmlæütè': 'µ¶§°¹²³±' });
Known issues
- Needs more/better tests and docs.
License
ISC