You've already forked codtracker-js
format: prettify entire project
This commit is contained in:
52
node_modules/path-to-regexp/index.js
generated
vendored
52
node_modules/path-to-regexp/index.js
generated
vendored
@ -41,13 +41,13 @@ function pathToRegexp(path, keys, options) {
|
||||
var m;
|
||||
|
||||
if (path instanceof RegExp) {
|
||||
while (m = MATCHING_GROUP_REGEXP.exec(path.source)) {
|
||||
while ((m = MATCHING_GROUP_REGEXP.exec(path.source))) {
|
||||
if (m[0][0] === '\\') continue;
|
||||
|
||||
keys.push({
|
||||
name: m[1] || name++,
|
||||
optional: false,
|
||||
offset: m.index
|
||||
offset: m.index,
|
||||
});
|
||||
}
|
||||
|
||||
@ -66,7 +66,9 @@ function pathToRegexp(path, keys, options) {
|
||||
}
|
||||
|
||||
if (typeof path !== 'string') {
|
||||
throw new TypeError('path must be a string, array of strings, or regular expression');
|
||||
throw new TypeError(
|
||||
'path must be a string, array of strings, or regular expression'
|
||||
);
|
||||
}
|
||||
|
||||
path = path.replace(
|
||||
@ -107,43 +109,57 @@ function pathToRegexp(path, keys, options) {
|
||||
slash = slash || '';
|
||||
format = format ? '\\.' : '';
|
||||
optional = optional || '';
|
||||
capture = capture ?
|
||||
capture.replace(/\\.|\*/, function (m) { return m === '*' ? '(.*)' : m; }) :
|
||||
(backtrack ? '((?:(?!/|' + backtrack + ').)+?)' : '([^/' + format + ']+?)');
|
||||
capture =
|
||||
capture ?
|
||||
capture.replace(/\\.|\*/, function (m) {
|
||||
return m === '*' ? '(.*)' : m;
|
||||
})
|
||||
: backtrack ? '((?:(?!/|' + backtrack + ').)+?)'
|
||||
: '([^/' + format + ']+?)';
|
||||
|
||||
keys.push({
|
||||
name: key,
|
||||
optional: !!optional,
|
||||
offset: offset + extraOffset
|
||||
offset: offset + extraOffset,
|
||||
});
|
||||
|
||||
var result = '(?:'
|
||||
+ format + slash + capture
|
||||
+ (star ? '((?:[/' + format + '].+?)?)' : '')
|
||||
+ ')'
|
||||
+ optional;
|
||||
var result =
|
||||
'(?:' +
|
||||
format +
|
||||
slash +
|
||||
capture +
|
||||
(star ? '((?:[/' + format + '].+?)?)' : '') +
|
||||
')' +
|
||||
optional;
|
||||
|
||||
extraOffset += result.length - match.length;
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// This is a workaround for handling unnamed matching groups.
|
||||
while (m = MATCHING_GROUP_REGEXP.exec(path)) {
|
||||
while ((m = MATCHING_GROUP_REGEXP.exec(path))) {
|
||||
if (m[0][0] === '\\') continue;
|
||||
|
||||
if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
|
||||
if (
|
||||
keysOffset + i === keys.length ||
|
||||
keys[keysOffset + i].offset > m.index
|
||||
) {
|
||||
keys.splice(keysOffset + i, 0, {
|
||||
name: name++, // Unnamed matching groups must be consistently linear.
|
||||
optional: false,
|
||||
offset: m.index
|
||||
offset: m.index,
|
||||
});
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
path += strict ? '' : path[path.length - 1] === '/' ? '?' : '/?';
|
||||
path +=
|
||||
strict ? ''
|
||||
: path[path.length - 1] === '/' ? '?'
|
||||
: '/?';
|
||||
|
||||
// If the path is non-ending, match until the end or a slash.
|
||||
if (end) {
|
||||
@ -153,4 +169,4 @@ function pathToRegexp(path, keys, options) {
|
||||
}
|
||||
|
||||
return new RegExp('^' + path, flags);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user