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

path-to-regex

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-to-regex - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "path-to-regex",
"version": "1.0.0",
"version": "1.0.1",
"description": "Turn a path string such as /user/:id or /user/:id(\\d+) into a regular expression",

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

@@ -7,4 +7,2 @@ # path-to-regex

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]

@@ -21,1 +19,40 @@ [![License][license-image]][license-url]

## Usage
```javascript
var pathToRegex = require('path-to-regex');
var matcher = new pathToRegex(path_template, options?);
```
- **path_template** A string or a regular expression.
- **options**
- **case** When `true` the regexp will be case sensitive. (default: `true`)
- **splitters** The chars list for splited patch string. (default: `'/'`)
- **escapeChars** The chars list for escaped. (default: `'/'`)
- **fromStart** When `true` the regexp will match from the beginning of the string. (default: `true`)
- **toEnd** When `true` the regexp will match to the end of the string. (default: `true`)
```javascript
var pathToRegex = require('path-to-regex');
var matcher = new pathToRegex('/foo/:bar');
// matcher.regexp = /^\/foo\/(?<bar>[^\/]+?)$/
// matcher.keys = [{key:'bar',pattern:'[^\\/]+?'}]
var result = matcher.match('/foo/12345');
// result = { bar: '12345' }
```
... documentation in processed
[npm-image]: https://img.shields.io/npm/v/path-to-regex.svg?style=flat
[npm-url]: https://npmjs.org/package/path-to-regex
[david-image]: http://img.shields.io/david/lastuniverse/path-to-regex.svg?style=flat
[david-url]: https://david-dm.org/lastuniverse/path-to-regex
[license-image]: http://img.shields.io/npm/l/path-to-regex.svg?style=flat
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/path-to-regex.svg?style=flat
[downloads-url]: https://npmjs.org/package/path-to-regex

@@ -62,3 +62,3 @@ const chai = require('chai');

const re3 = new PathToRegex("/foo/:fooid/bar/:barid");
// console.log("REGEX:", "\t\t"+re3.regexp, "\t\t", re3.regexp, "\t\t", re3.regstr, "\t\t", re3.path);
it("создаем RegExp из \"/foo/:fooid/bar/:barid\"", function() {

@@ -75,2 +75,4 @@ assert.equal( re3 instanceof PathToRegex, true);

const params = re3.match("/foo/123/bar/456");
console.log("REGEX:", "\t\t"+re3.regexp, "\t\t", re3.regexp, "\t\t", re3.regstr, "\t\t", re3.path, "\t\t", re3.keys);
console.log("REGEX:", "\t\t", params);
assert.equal( !!params, true);

@@ -77,0 +79,0 @@ });

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