Skip to content

Instantly share code, notes, and snippets.

@hiroppy
Last active March 24, 2017 10:31
Show Gist options
  • Save hiroppy/f28edff08588e5c179dce791b8b92fe8 to your computer and use it in GitHub Desktop.
Save hiroppy/f28edff08588e5c179dce791b8b92fe8 to your computer and use it in GitHub Desktop.
WHATWG URL
const { URLSearchParams } = require('url');
const params = new URLSearchParams('foo=bar&hoge=fuga&foo=baz');
// URLSearchParams { 'foo' => 'bar', 'foo' => 'baz', 'hoge' => 'fuga' }
console.log(params.toString()); // foo=bar&foo=baz&hoge=fuga
params.sort();
// URLSearchParams { 'foo' => 'bar', 'foo' => 'baz', 'hoge' => 'fuga' }
console.log(params.toString()); // foo=bar&foo=baz&hoge=fuga
@hiroppy
Copy link
Author

hiroppy commented Mar 24, 2017

L4: Is it okay to sort it still we don't run sort()?
We should expect foo=bar&hoge=fuga&foo=baz?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment