🚀 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

A simple module to extract query parameters from URL

1.0.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

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:

  • 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

  • It uses window.location.href to get URL of current page.

  • If the specified key doesn't exists in query string than it returns null.

  • If the specified key doesn't has any value than it returns ```''````.

Keywords

query

FAQs

Package last updated on 07 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts