Merge branch 'hotfix/21.56.9' into master
[gitter.git] / public / js / utils / slugger.js
blob9f94bfe985cb13e8d9e94268291f662589876dff
1 'use strict';
3 function slugger(text) {
4 const trimmedText = text.trim();
5 const parts = trimmedText.split(/[^\p{L}\d_]+/u);
7 return parts
8 .filter(function(part) {
9 return part.length > 0;
11 .join('-');
14 function isValid(text) {
15 return /^[\p{L}\d_-]+$/u.test(text);
18 module.exports = slugger;
19 module.exports.isValid = isValid;