Socket
Socket
Sign inDemoInstall

path-parser

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-parser

A small utility to parse paths


Version published
Weekly downloads
92K
increased by15.61%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Build Status Coverage Status

path-parser

A small utility to parse and build paths. It can be used to partially or fully match paths against a defined pattern.

Partial match allows to determine if a given path starts with the defined pattern. It is used by route-node

Usage

var Path = require('path-parser');
// Defining a new path
var p = new Path('/users/profile/:id');
// Matching
p.match('/users/profile/00123')               // => {id: "00123"}
// Partial matching: does this path
// starts with that pattern?
p.partialMatch('/users/profile/00123/orders') // => {id: "00123"}
p.partialMatch('/profile/00123/orders')       // => false
// Building
p.build({id: '00123'})                       // => "users/profile/00123"

Defining parameters

  • :param: for URL parameters
  • *splat: for parameters spanning over multiple segments. Handle with care
  • ?param1&param2 or ?:param1&:param2: for query parameters. Colons : are optional

Keywords

FAQs

Package last updated on 30 Jun 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