extract URL query params
npm install query-parameters> IMPORTANT NOTE
>
> I reinvented the wheel, I know... This project was created with the intention of being used within my own personal projects. If you are building anything of importance, you're probably better off using a more popular alternative with more comprehensive tests such as this one or this.
This small package helps you extract query parameters from a URL string.
Install the component via npm by running npm i query-parameters or yarn add query-parameters.
``js
const extract = require('query-parameters')
extract('https://www.website.com?id=123')
// returns { id: '123' }
`
Parameter values can be specified as arrays.
`js`
extract('https://www.website.com?post[]=1')
// returns { post: ['1'] }
The value's index in the array can also be specified.
`js`
extract('https://www.website.com?post[1]=second&post[0]=first')
// returns { post: ['first', 'second'] }
If multiple parameter values with the same key are provided, the output will be an array of values.
`js`
extract('https://www.website.com?post=1&post=2')
// returns { post: ['1', '2'] }
Feel free to discuss any bug fixes/features in the issues. If you wish to work on this project:
1. Fork the project
2. Create your feature branch (git checkout -b new-feature-branch)git commit -am 'add new feature'
3. Commit your changes & check for any lint/test output ()git push origin new-feature-branch`)
4. Push to the branch (
5. Submit a pull request!