New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.3.1 to 1.3.2

.github/workflows/npmpublish.yml

43

index.js
module.exports = Regex;
if(window){
window.pathToRegex = Regex;
}
const escapeRe = /([$.+*?=!:[\]{}(|)/\\])/g;
/**
* defaultParam - simplistic polyfill for default function parament
* @param {any} [obj]
* @param {any} defaultValue
* @return {any}
*/
function defaultParam(obj, defaultValue) {
return typeof obj !== 'undefined' ? obj : defaultValue;
}

@@ -21,7 +34,7 @@ /**

this.options = {
case: options.case || true,
separators: options.separators || "/",
fromStart: options.fromStart || true,
toEnd: options.toEnd || true
}
case: typeof options.case === "boolean"? options.case : true,
separators: typeof options.separators === "string"? options.separators : "/",
fromStart: typeof options.fromStart === "boolean"? options.fromStart : true,
toEnd: typeof options.toEnd === "boolean"? options.toEnd : true
};
this.options.separator = "[" + this.escape(this.options.separators) + "]";

@@ -37,8 +50,9 @@

/**
* Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений
* Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений
* и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение
* @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x
*/
Regex.prototype.restructureRegExp = function(regexp = /.*/) {
this.keys = [];
Regex.prototype.restructureRegExp = function(regexp) {
regexp = defaultParam(regexp, /.*/);
this.keys = [];
this.path = undefined;

@@ -55,8 +69,9 @@ this.regstr = ("" + regexp);

/**
* Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений
* Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений
* и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение
* @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x
*/
Regex.prototype.restructurePath = function(path = "/") {
this.keys = [];
Regex.prototype.restructurePath = function(path) {
path = defaultParam(path, '/');
this.keys = [];
this.path = path;

@@ -153,4 +168,4 @@ this.regstr = "";

* Метод экранирует все спец символы указанные в глобальной для модуля, переменной escapeRe
* @param {string} text Любая строка
* @return {string} Строка text, в которой все символы указанные в переменной escapeRe заэкранированы
* @param {string} text Любая строка
* @return {string} Строка text, в которой все символы указанные в переменной escapeRe заэкранированы
*/

@@ -178,3 +193,3 @@ Regex.prototype.escape = function(text) {

if (typeof path !== "string") return;
// console.log("match 02");

@@ -181,0 +196,0 @@ const result = path.match(this.regexp);

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

@@ -36,2 +36,2 @@ "main": "index.js",

"homepage": "https://github.com/lastuniverse/path-to-regex#readme"
}
}

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

## Tests
[Tests](http://jsfiddle.net/zb0vwqsd/)

@@ -203,2 +205,2 @@ ## Participation in development

[downloads-image]: http://img.shields.io/npm/dm/path-to-regex.svg?style=flat
[downloads-url]: https://npmjs.org/package/path-to-regex
[downloads-url]: https://npmjs.org/package/path-to-regex
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