🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

query-extractor

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-extractor - npm Package Compare versions

Comparing version

to
1.0.1

2

package.json
{
"name": "query-extractor",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple module to extract query parameters from URL",

@@ -5,0 +5,0 @@ "main": "index.js",

# query-extractor
A simple module to get query parameters from a url
## Usage
Require
var query = require('query-extractor');
Get all query parameters and their values in an object
query.getAll("https://awesomewebsite.com?name=canon&place=India");
Output
{ name: 'canon', place: 'India' }
Get the value for a specific key in query string
query.get("https://awesomewebsite.com?name=canon&place=India", "name");
Output
canon
### Note:
1. The URL in function is optional, If you want it to use the URL of current page than pass ```null``` instead and it'll use URL of current page
2. It uses window.location.href to get URL of current page.
3. If the specified key doesn't exists in query string than it returns ```null```.
4. If the specified key doesn't has any value than it returns ```''````.