Skip to content

KooiInc/QueryParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QueryParser

Parse a querystring, maintaining '&' or ''=' in values

This small library can parse a querystring into a collection of key and value pairs where values may contain '&' or '=' (which wrecks the usual parsing).

example string: "?something=hithere & here I am&somethingelse=1=1&all ok"

Just make sure ampersands in a value are either postfixed with a whitespace character or prefixed with a ^. So the previous example should be: "something=hithere & here I am&somethingelse=1=1^&all ok".

Parsing the example with this library results in:

{ something: 'hithere & here I am',
  somethingelse: '1=1&all ok' }

Not a panacea

The library is not a panacea for all querystring problems one may encounter. If you want to circumvent querystring problems, don't use GET requests for keys with a lot of content in its value. In other words: keep your querystring as simple as possible and use POST for large queries. Alternatively you can use nodejs' Querystring.parse, or use your own delimiters (so, not & and/or =) and write your own parser for that.

About

Parse a querystring, maintaining & in values

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published