Skip to content

Commit 28ffc13

Browse files
committed
Don't allow leading or trailing whitespace for the exact regex option
1 parent 1d5d717 commit 28ffc13

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
module.exports = function(options) {
44
options = options || {};
5-
var regexBase = '\\s*(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?\\s*';
5+
var regexBase = '(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?';
66

77
return options.exact ? new RegExp('^' + regexBase + '$') :
8-
new RegExp(regexBase, 'g');
8+
new RegExp('\\s*' + regexBase + '\\s*', 'g');
99
}

0 commit comments

Comments
 (0)