From 342136ad24ac7008a49e708c3ee178ca01bdfddc Mon Sep 17 00:00:00 2001 From: Charles Lee Date: Mon, 23 Oct 2017 14:39:40 +1100 Subject: [PATCH] replace trim fn loop with regex --- src/utils/trim.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/utils/trim.js b/src/utils/trim.js index 502f824a3a..87cc1c3182 100644 --- a/src/utils/trim.js +++ b/src/utils/trim.js @@ -1,10 +1,3 @@ module.exports = function trim(str) { - str = str.replace(/^\s+/, ''); - for (var i = str.length - 1; i >= 0; i--) { - if (/\S/.test(str.charAt(i))) { - str = str.substring(0, i + 1); - break; - } - } - return str; -}; \ No newline at end of file + return str.replace(/^\s+|\s+$/g, ''); +};