Skip to content

Commit

Permalink
[minor] Simplify whitespace regex
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Feb 13, 2022
1 parent 319851b commit 193b44b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var required = require('requires-port')
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
, windowsDriveLetter = /^[a-zA-Z]:/
, 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]'
, left = new RegExp('^'+ whitespace +'+');
, whitespace = /^[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;

/**
* Trim a given string.
Expand All @@ -16,7 +15,7 @@ var required = require('requires-port')
* @public
*/
function trimLeft(str) {
return (str ? str : '').toString().replace(left, '');
return (str ? str : '').toString().replace(whitespace, '');
}

/**
Expand Down

0 comments on commit 193b44b

Please sign in to comment.