Compare commits
No commits in common. "37ccc3c3dd8ebe31e42860e44e22899f22bf6bf6" and "0e23115cfed1a4776005052c237eb2162c2b1548" have entirely different histories.
37ccc3c3dd
...
0e23115cfe
2
common
2
common
|
|
@ -1 +1 @@
|
||||||
Subproject commit ec4b15ce33a3a6306ee5024935ed2966502d3019
|
Subproject commit ee23dc0358677a66b27a20b8d56c4b69782cec9b
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx-web",
|
"name": "traxxx-web",
|
||||||
"version": "0.42.5",
|
"version": "0.42.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.42.5",
|
"version": "0.42.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brillout/json-serializer": "^0.5.8",
|
"@brillout/json-serializer": "^0.5.8",
|
||||||
"@dicebear/collection": "^7.0.5",
|
"@dicebear/collection": "^7.0.5",
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"vite": "$vite"
|
"vite": "$vite"
|
||||||
},
|
},
|
||||||
"version": "0.42.5",
|
"version": "0.42.4",
|
||||||
"imports": {
|
"imports": {
|
||||||
"#/*": "./*.js"
|
"#/*": "./*.js"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,136 +1,3 @@
|
||||||
const accentMap = {
|
import slugify from '../../common/slugify.cjs';
|
||||||
à: 'a',
|
|
||||||
á: 'a',
|
|
||||||
ä: 'a',
|
|
||||||
å: 'a',
|
|
||||||
ã: 'a',
|
|
||||||
â: 'a',
|
|
||||||
æ: 'ae',
|
|
||||||
ç: 'c',
|
|
||||||
è: 'e',
|
|
||||||
é: 'e',
|
|
||||||
ë: 'e',
|
|
||||||
ẽ: 'e',
|
|
||||||
ê: 'e',
|
|
||||||
ì: 'i',
|
|
||||||
í: 'i',
|
|
||||||
ï: 'i',
|
|
||||||
ĩ: 'i',
|
|
||||||
î: 'i',
|
|
||||||
ǹ: 'n',
|
|
||||||
ń: 'n',
|
|
||||||
ñ: 'n',
|
|
||||||
ò: 'o',
|
|
||||||
ó: 'o',
|
|
||||||
ö: 'o',
|
|
||||||
õ: 'o',
|
|
||||||
ô: 'o',
|
|
||||||
ø: 'o',
|
|
||||||
œ: 'oe',
|
|
||||||
ß: 'ss',
|
|
||||||
ù: 'u',
|
|
||||||
ú: 'u',
|
|
||||||
ü: 'u',
|
|
||||||
ũ: 'u',
|
|
||||||
û: 'u',
|
|
||||||
ỳ: 'y',
|
|
||||||
ý: 'y',
|
|
||||||
ÿ: 'y',
|
|
||||||
ỹ: 'y',
|
|
||||||
};
|
|
||||||
|
|
||||||
const plainCharRegex = /[a-zA-Z0-9]/;
|
export default slugify;
|
||||||
const defaultPunctuationRegex = /[.,?!:;&'‘’"“”…()[]{}<>\/*—-]/;
|
|
||||||
const defaultSymbolRegex = /[@$€£#%^+=\\~]/;
|
|
||||||
|
|
||||||
export default function slugify(strings, delimiter = '-', {
|
|
||||||
limit = 1000,
|
|
||||||
lower = true,
|
|
||||||
encode = false,
|
|
||||||
accents: keepAccents = false,
|
|
||||||
punctuation: keepPunctuation = false,
|
|
||||||
punctuationRegex = defaultPunctuationRegex,
|
|
||||||
symbols: keepSymbols = false,
|
|
||||||
symbolRegex = defaultSymbolRegex,
|
|
||||||
} = {}) {
|
|
||||||
if (!strings || (typeof strings !== 'string' && !Array.isArray(strings))) {
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
|
|
||||||
const string = [].concat(strings).join(' ');
|
|
||||||
|
|
||||||
const casedString = lower
|
|
||||||
? string.toLowerCase()
|
|
||||||
: string;
|
|
||||||
|
|
||||||
const normalized = casedString
|
|
||||||
.split('')
|
|
||||||
.map((char) => {
|
|
||||||
if (char === ' ') {
|
|
||||||
return char;
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowChar = char.toLowerCase();
|
|
||||||
|
|
||||||
if (accentMap[lowChar]) {
|
|
||||||
if (keepAccents) {
|
|
||||||
return char;
|
|
||||||
}
|
|
||||||
|
|
||||||
// match original case after mapping
|
|
||||||
if (char === lowChar) {
|
|
||||||
return accentMap[lowChar];
|
|
||||||
}
|
|
||||||
|
|
||||||
return accentMap[lowChar].toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plainCharRegex.test(char)) {
|
|
||||||
return char;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (punctuationRegex.test(char)) {
|
|
||||||
if (keepPunctuation === 'split') {
|
|
||||||
return ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keepPunctuation) {
|
|
||||||
return char;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (symbolRegex.test(char)) {
|
|
||||||
if (keepSymbols === 'split') {
|
|
||||||
return ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keepSymbols) {
|
|
||||||
return char;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}).join('');
|
|
||||||
|
|
||||||
const components = normalized.trim().split(/\s+/).filter(Boolean);
|
|
||||||
|
|
||||||
if (components.length === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const slug = components.reduce((acc, component, index) => {
|
|
||||||
const accSlug = `${acc}${index > 0 ? delimiter : ''}${component}`;
|
|
||||||
|
|
||||||
if (accSlug.length < limit) {
|
|
||||||
return accSlug;
|
|
||||||
}
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}).slice(0, limit); // in case first word exceeds limit
|
|
||||||
|
|
||||||
if (encode) {
|
|
||||||
return encodeURI(slug);
|
|
||||||
}
|
|
||||||
|
|
||||||
return slug;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue