summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/text_utility.js
diff options
context:
space:
mode:
authorMartin Wortschack <mwortschack@gitlab.com>2018-09-08 06:03:00 +0000
committerTim Zallmann <tzallmann@gitlab.com>2018-09-08 06:03:00 +0000
commit03ab130e4b112d51ce77260e54d42b44126426c7 (patch)
tree4009b561f17a300fa33a19872984fb7b54729c00 /app/assets/javascripts/lib/utils/text_utility.js
parent1d69d26f9f4c950f7c42ad4a7de2f95e11475172 (diff)
downloadgitlab-ce-03ab130e4b112d51ce77260e54d42b44126426c7.tar.gz
Resolve "Create new project: Re-add project name field"
Diffstat (limited to 'app/assets/javascripts/lib/utils/text_utility.js')
-rw-r--r--app/assets/javascripts/lib/utils/text_utility.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js
index 2be3c97bd95..879f94a26ec 100644
--- a/app/assets/javascripts/lib/utils/text_utility.js
+++ b/app/assets/javascripts/lib/utils/text_utility.js
@@ -49,6 +49,16 @@ export const dasherize = str => str.replace(/[_\s]+/g, '-');
export const slugify = str => str.trim().toLowerCase();
/**
+ * Replaces whitespaces with hyphens and converts to lower case
+ * @param {String} str
+ * @returns {String}
+ */
+export const slugifyWithHyphens = str => {
+ const regex = new RegExp(/\s+/, 'g');
+ return str.toLowerCase().replace(regex, '-');
+};
+
+/**
* Truncates given text
*
* @param {String} string