Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

query-path

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-path

helper methods to work with URL query string and pathname

  • 1.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

query-path

helper methods to parse url pathname and querystring

Install

$ npm install --save query-path

Usage

const queryPath = require('query-path');

console.log(queryPath.queryStringByKey('name','http://example.com?name=joe'));
//=> 'joe'

//if window url bar equals 'http://example.com?name=chandler'
console.log(queryPath.queryStringByKey('name'));
//=> 'chandler'

console.log(queryPath.pathByIndex(1,'http://exmaple.com/xyz/abc'));
//=> 'abc'

console.log(queryPath.pathByRegex('first'),'http://example.com/firstsecond/secondfirst/thirdsecond');
//=> ['firstsecond','secondfirst']

API

.queryStringByKey(string,string)

parse a url queryString and provide output based on key. In case second input parameter 'url' is not provided it will take browser URL location.

.pathByIndex(int,string)

parse window.location.pathname for browser url or '/' separated path in provided url and give path value based on zero based index.

.pathByRegex(string,string)

parse window.location.path for browser url or '/' separated path in provided url and give matching path values as an array for provided regex.

License

MIT © Abhijeet Mishra

Keywords

FAQs

Package last updated on 30 Nov 2015

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