Use literal instead of constructor for creating regex

This commit is contained in:
Martin Wortschack 2018-10-15 15:32:47 +02:00
parent 280a132e15
commit d0191e294f
2 changed files with 6 additions and 4 deletions

View File

@ -53,10 +53,7 @@ export const slugify = str => str.trim().toLowerCase();
* @param {String} str
* @returns {String}
*/
export const slugifyWithHyphens = str => {
const regex = new RegExp(/\s+/, 'g');
return str.toLowerCase().replace(regex, '-');
};
export const slugifyWithHyphens = str => str.toLowerCase().replace(/\s+/g, '-');
/**
* Truncates given text

View File

@ -0,0 +1,5 @@
---
title: Use literal instead of constructor for creating regex
merge_request: 22367
author:
type: other