From e5d08e764dd6420d27bfebb2bafc0a63665926f8 Mon Sep 17 00:00:00 2001 From: Daniel Karadachki Date: Fri, 5 Jul 2019 13:26:46 +0300 Subject: [PATCH] refactor: format spaces --- src/dates/parse-date.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dates/parse-date.js b/src/dates/parse-date.js index 08c2f12f..2cc926a9 100644 --- a/src/dates/parse-date.js +++ b/src/dates/parse-date.js @@ -18,8 +18,8 @@ const numberRegExp = { const numberRegex = /\d+/; const PLACEHOLDER = "{0}"; -const leadingSpacesRegex = /^ +/; -const trailingSpacesRegex = / +$/; +const leadingSpacesRegex = /^ */; +const trailingSpacesRegex = / *$/; const standardDateFormats = [ "yyyy/MM/dd HH:mm:ss", @@ -460,8 +460,8 @@ function createDate(state) { } function addFormatSpaces(value, format) { - const leadingSpaces = (leadingSpacesRegex.exec(format) || [])[0] || ''; - const trailingSpaces = (trailingSpacesRegex.exec(format) || [])[0] || ''; + const leadingSpaces = leadingSpacesRegex.exec(format)[0]; + const trailingSpaces = trailingSpacesRegex.exec(format); return `${ leadingSpaces }${ value }${ trailingSpaces }`; }