Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
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:

  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 ```''````.

Keywords

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc