summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib
diff options
context:
space:
mode:
authorOlivier Gonzalez <ogonzalez@gitlab.com>2018-05-03 08:25:22 +0000
committerPhil Hughes <me@iamphill.com>2018-05-03 08:25:22 +0000
commitb12d6546afba081a1fd64877daaf30b68efba618 (patch)
treeaee43f3ffdfda3ad0a4a2d2ba7d0430315bcabff /app/assets/javascripts/lib
parent6aad7b4941a2e35177b8e175c86bd3558e1a2b59 (diff)
downloadgitlab-ce-b12d6546afba081a1fd64877daaf30b68efba618.tar.gz
Add pass through to stripHtml for undefined and null inputs
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r--app/assets/javascripts/lib/utils/text_utility.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js
index b54ecd2d543..5e786ee6935 100644
--- a/app/assets/javascripts/lib/utils/text_utility.js
+++ b/app/assets/javascripts/lib/utils/text_utility.js
@@ -74,7 +74,11 @@ export function capitalizeFirstCharacter(text) {
* @param {*} replace
* @returns {String}
*/
-export const stripHtml = (string, replace = '') => string.replace(/<[^>]*>/g, replace);
+export const stripHtml = (string, replace = '') => {
+ if (!string) return string;
+
+ return string.replace(/<[^>]*>/g, replace);
+};
/**
* Converts snake_case string to camelCase