diff options
author | Paul Gascou-Vaillancourt <pgascouvaillancourt@gitlab.com> | 2019-05-28 07:53:44 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-05-28 07:53:44 +0000 |
commit | dade5a44ec1ea8164c4363ba86f1806c70cd3642 (patch) | |
tree | 5536b7bda8038ef56af9d91ab4f1b455850a94f0 /app/assets/javascripts/lib | |
parent | ff7766b954984f448428cc153351db55029ccc8a (diff) | |
download | gitlab-ce-dade5a44ec1ea8164c4363ba86f1806c70cd3642.tar.gz |
Throw an error when formatDate's input is invalid
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime_utility.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index 624878cb5d7..32cafb74d91 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -79,7 +79,12 @@ export const getDayName = date => * @param {date} datetime * @returns {String} */ -export const formatDate = datetime => dateFormat(datetime, 'mmm d, yyyy h:MMtt Z'); +export const formatDate = datetime => { + if (_.isString(datetime) && datetime.match(/\d+-\d+\d+ /)) { + throw new Error('Invalid date'); + } + return dateFormat(datetime, 'mmm d, yyyy h:MMtt Z'); +}; /** * Timeago uses underscores instead of dashes to separate language from country code. |