Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-26 21:08:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-26 21:08:03 +0300
commitdc003cd08b4cb72fecbb03aa978ea0c53c03aeb4 (patch)
tree5e77ce228c33619201ac6706b9789d4a2eed2a3b /app/assets/javascripts/frequent_items
parente80e0dd64fbb04f60394cb1bb08e17dbcb22b8ce (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/frequent_items')
-rw-r--r--app/assets/javascripts/frequent_items/utils.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/assets/javascripts/frequent_items/utils.js b/app/assets/javascripts/frequent_items/utils.js
index a992480c22b..d4b7ffdcbe1 100644
--- a/app/assets/javascripts/frequent_items/utils.js
+++ b/app/assets/javascripts/frequent_items/utils.js
@@ -45,8 +45,19 @@ export const updateExistingFrequentItem = (frequentItem, item) => {
};
};
-export const sanitizeItem = item => ({
- ...item,
- name: sanitize(item.name.toString(), { allowedTags: [] }),
- namespace: sanitize(item.namespace.toString(), { allowedTags: [] }),
-});
+export const sanitizeItem = item => {
+ // Only sanitize if the key exists on the item
+ const maybeSanitize = key => {
+ if (!Object.prototype.hasOwnProperty.call(item, key)) {
+ return {};
+ }
+
+ return { [key]: sanitize(item[key].toString(), { allowedTags: [] }) };
+ };
+
+ return {
+ ...item,
+ ...maybeSanitize('name'),
+ ...maybeSanitize('namespace'),
+ };
+};