Add a JavaScript utility function for parsing query strings in URLs.
Review Request #9711 — Created March 1, 2018 and submitted
This introduces
Djblets.parseQueryString()
, which will take a query
string or a URL containing one and parse it. It understands key/value
pairs, standalone keys (which will be assigned the valuenull
), and
optionally supports storing multiple values for a key as an array.Unit tests were added that test all the standard query string cases.
Unit tests pass.
Used this in an upcoming change in Review Board.
-
-
-
djblets/static/djblets/js/utils/urls.es6.js (Diff revision 1) Given the default value for
options
, I think you don't need this check and can just useoptions.allowMultiValue
. If someone passes in something that's falsy and not an object they're using the API wrong. -
djblets/static/djblets/js/utils/urls.es6.js (Diff revision 1) Can we move the
decodeURIComponent
call into the if/else above?
Change Summary:
- Marked
options
as optional in the docs. - Removed an unnecessary check for
options
being defined.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+129) |
Checks run (2 succeeded)
Change Summary:
- Switched to using
decodeURIComponent()
in the initial assignments, instead of after.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+127) |