Skip to content

Commit e689dd6

Browse files
committed
Remove usage of map from array input
1 parent ab2f474 commit e689dd6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

index.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,17 @@ function pathtoRegexp (path, keys, options) {
9191
return attachKeys(path, keys);
9292
}
9393

94+
// Map array parts into regexps and return their source. We also pass
95+
// the same keys and options instance into every generation to get
96+
// consistent matching groups before we join the sources together.
9497
if (Array.isArray(path)) {
95-
// Map array parts into regexps and return their source. We also pass
96-
// the same keys and options instance into every generation to get
97-
// consistent matching groups before we join the sources together.
98-
path = path.map(function (value) {
99-
return pathtoRegexp(value, keys, options).source;
100-
});
98+
var parts = [];
10199

100+
for (var i = 0; i < path.length; i++) {
101+
parts.push(pathtoRegexp(path[i], keys, options).source);
102+
}
102103
// Generate a new regexp instance by joining all the parts together.
103-
return attachKeys(new RegExp('(?:' + path.join('|') + ')', flags), keys);
104+
return attachKeys(new RegExp('(?:' + parts.join('|') + ')', flags), keys);
104105
}
105106

106107
// Alter the path string into a usable regexp.

0 commit comments

Comments
 (0)