Skip to content

Commit 193b44b

Browse files
committedFeb 13, 2022
[minor] Simplify whitespace regex
1 parent 319851b commit 193b44b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ var required = require('requires-port')
66
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
77
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
88
, windowsDriveLetter = /^[a-zA-Z]:/
9-
, whitespace = '[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]'
10-
, left = new RegExp('^'+ whitespace +'+');
9+
, whitespace = /^[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
1110

1211
/**
1312
* Trim a given string.
@@ -16,7 +15,7 @@ var required = require('requires-port')
1615
* @public
1716
*/
1817
function trimLeft(str) {
19-
return (str ? str : '').toString().replace(left, '');
18+
return (str ? str : '').toString().replace(whitespace, '');
2019
}
2120

2221
/**

0 commit comments

Comments
 (0)
Please sign in to comment.