Socket
Socket
Sign inDemoInstall

regexparam

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.2.0

4

dist/regexparam.js

@@ -1,2 +0,2 @@

module.exports = function (str) {
module.exports = function (str, loose) {
var c, o, tmp, ext, keys=[], pattern='', arr=str.split('/');

@@ -23,4 +23,4 @@ arr[0] || arr.shift();

keys: keys,
pattern: new RegExp('^' + pattern + '\/?$', 'i')
pattern: new RegExp('^' + pattern + (loose ? '(?:$|\/)' : '\/?$'), 'i')
};
}
{
"name": "regexparam",
"version": "1.1.1",
"version": "1.2.0",
"repository": "lukeed/regexparam",
"description": "A tiny (276B) utility that converts route patterns into RegExp. Limited alternative to `path-to-regexp` 🙇‍",
"description": "A tiny (285B) utility that converts route patterns into RegExp. Limited alternative to `path-to-regexp` 🙇‍",
"module": "dist/regexparam.mjs",

@@ -7,0 +7,0 @@ "main": "dist/regexparam.js",

# regexparam [![Build Status](https://travis-ci.org/lukeed/regexparam.svg?branch=master)](https://travis-ci.org/lukeed/regexparam)
> A tiny (276B) utility that converts route patterns into RegExp. Limited alternative to [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) 🙇
> A tiny (285B) utility that converts route patterns into RegExp. Limited alternative to [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) 🙇

@@ -93,8 +93,6 @@ With `regexparam`, you may turn a pathing string (eg, `/users/:id`) into a regular expression.

### regexparam(str)
### regexparam(str, loose)
Returns: `Object`
#### str
Type: `String`

@@ -106,3 +104,20 @@

#### loose
Type: `Boolean`<br>
Default: `false`
Should the `RegExp` match URLs that are longer than the [`str`](#str) pattern itself?<br>
By default, the generated `RegExp` will test that the URL begins and _ends with_ the pattern.
```js
const rgx = require('regexparam');
rgx('/users').pattern.test('/users/lukeed'); //=> false
rgx('/users', true).pattern.test('/users/lukeed'); //=> true
rgx('/users/:name').pattern.test('/users/lukeed/repos'); //=> false
rgx('/users/:name', true).pattern.test('/users/lukeed/repos'); //=> true
```
## Related

@@ -109,0 +124,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc