Commit d1e892d3 authored by Jamie Tanna's avatar Jamie Tanna

Add the ability to specify a parameter for query/fragment parsing

parent 14ffb374
Pipeline #123327414 failed with stage
in 7 minutes and 53 seconds
......@@ -32,8 +32,8 @@ console.log(JSON.stringify(fragmentParams, null, 4));
Also note that yes, this should be received by your browser, not by some Node code which runs on the backend, but for the purpose I've been testing it with, the Node code for it was important.
And for a handy one-liner:
And for a handy one-liner, which will let you optionally specify the parameter to display:
```sh
$ echo 'https://example.com/auth/callback#code=foo&state=blah' | node -r querystring -r url -e 'console.log(JSON.stringify(querystring.parse(url.parse(fs.readFileSync("/dev/stdin", "utf-8")).hash.replace("#", "")), null, 4))'
$ echo 'https://example.com/auth/callback#code=foo&state=blah' | node -r querystring -r url -e 'q = querystring.parse(url.parse(fs.readFileSync("/dev/stdin", "utf-8")).hash.replace("#", ""));console.log((process.argv.slice(0)[1]) ? (q[process.argv.slice(0)[1]] || "") : JSON.stringify(q, null, 4));'
```
......@@ -32,8 +32,9 @@ console.log(JSON.stringify(querystringParams, null, 4));
*/
```
And for a handy one-liner:
And for a handy one-liner, which will let you optionally specify the parameter to display:
```sh
$ echo 'https://example.com/auth/callback?code=foo&state=blah' | node -r fs -r querystring -r url -e 'console.log(JSON.stringify(querystring.parse(url.parse(fs.readFileSync("/dev/stdin", "utf-8")).query), null, 4))'
# note the required use of `--` at the end!
$ echo 'https://example.com/auth/callback?code=foo&state=blah' | node -r fs -r process -r querystring -r url -e 'q = querystring.parse(url.parse(fs.readFileSync("/dev/stdin", "utf-8")).query);console.log((process.argv.slice(0)[1]) ? (q[process.argv.slice(0)[1]] || "") : JSON.stringify(q, null, 4));' -- code
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment