summaryrefslogtreecommitdiff
path: root/spec/javascripts/helpers/vue_component_helper.js
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-04-16 18:01:09 +0000
committerClement Ho <clemmakesapps@gmail.com>2018-04-16 18:01:09 +0000
commit1cc633c8eca52fe794c9db0b1373023eb67666d7 (patch)
tree356936f8e70b50dfc0c33cb773a40a34f385fb6f /spec/javascripts/helpers/vue_component_helper.js
parentd103a567d6a8802f6c78ff55de674a73c7a7ad0f (diff)
downloadgitlab-ce-1cc633c8eca52fe794c9db0b1373023eb67666d7.tar.gz
Adds helpers to remove withespace and linebreaks
Diffstat (limited to 'spec/javascripts/helpers/vue_component_helper.js')
-rw-r--r--spec/javascripts/helpers/vue_component_helper.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/javascripts/helpers/vue_component_helper.js b/spec/javascripts/helpers/vue_component_helper.js
index 257c9f5526a..e0fe18e5560 100644
--- a/spec/javascripts/helpers/vue_component_helper.js
+++ b/spec/javascripts/helpers/vue_component_helper.js
@@ -1,3 +1,18 @@
-export default function removeBreakLine (data) {
- return data.replace(/\r?\n|\r/g, ' ');
-}
+/**
+ * Replaces line break with an empty space
+ * @param {*} data
+ */
+export const removeBreakLine = data => data.replace(/\r?\n|\r/g, ' ');
+
+/**
+ * Removes line breaks, spaces and trims the given text
+ * @param {String} str
+ * @returns {String}
+ */
+export const trimText = str =>
+ str
+ .replace(/\r?\n|\r/g, '')
+ .replace(/\s\s+/g, ' ')
+ .trim();
+
+export const removeWhitespace = str => str.replace(/\s\s+/g, ' ');