mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 17:37:24 +08:00
25 lines
927 B
JavaScript
25 lines
927 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.slugify = void 0;
|
|
// string.js slugify drops non ascii chars so we have to
|
|
// use a custom implementation here
|
|
const removeDiacritics = require('diacritics').remove;
|
|
// eslint-disable-next-line no-control-regex
|
|
const rControl = /[\u0000-\u001f]/g;
|
|
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g;
|
|
exports.slugify = (str) => {
|
|
return (removeDiacritics(str)
|
|
// Remove control characters
|
|
.replace(rControl, '')
|
|
// Replace special characters
|
|
.replace(rSpecial, '-')
|
|
// Remove continous separators
|
|
.replace(/\-{2,}/g, '-')
|
|
// Remove prefixing and trailing separtors
|
|
.replace(/^\-+|\-+$/g, '')
|
|
// ensure it doesn't start with a number (#121)
|
|
.replace(/^(\d)/, '_$1')
|
|
// lowercase
|
|
.toLowerCase());
|
|
};
|
|
//# sourceMappingURL=slugify.js.map
|