Compare commits
No commits in common. "0e23115cfed1a4776005052c237eb2162c2b1548" and "7a452db2f89bad4666e37d2f3ad8586c058438aa" have entirely different histories.
0e23115cfe
...
7a452db2f8
2
common
2
common
|
|
@ -1 +1 @@
|
||||||
Subproject commit ee23dc0358677a66b27a20b8d56c4b69782cec9b
|
Subproject commit c45852d6937abe25e1205af0b9b96d49970901c8
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx-web",
|
"name": "traxxx-web",
|
||||||
"version": "0.42.4",
|
"version": "0.42.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.42.4",
|
"version": "0.42.3",
|
||||||
"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.4",
|
"version": "0.42.3",
|
||||||
"imports": {
|
"imports": {
|
||||||
"#/*": "./*.js"
|
"#/*": "./*.js"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
import slugify from '../utils/slugify.js';
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
const cases = [
|
|
||||||
'Brave, New World',
|
|
||||||
'Jœrgenbahn Straße',
|
|
||||||
'Partêrre',
|
|
||||||
'Ápres ski.',
|
|
||||||
'very 😀 true 😃',
|
|
||||||
'a véééry long piece of text that should not result in a very long slug, even for $100',
|
|
||||||
'don\'t you, forget about me',
|
|
||||||
'Pneumonoultramicroscopicsilicovolcanoconiosis',
|
|
||||||
'this (old) spicemen[sic]',
|
|
||||||
'contact@example.com',
|
|
||||||
'!@#$%',
|
|
||||||
'',
|
|
||||||
' ',
|
|
||||||
['this is', '2026-01-01', 'an array', '', ' ', 'test'],
|
|
||||||
];
|
|
||||||
|
|
||||||
cases.forEach((item) => console.log(item, '-->', slugify(item, '-', { limit: 20 })));
|
|
||||||
|
|
||||||
cases.forEach((item) => console.log(item, '-->', slugify(item, '-', {
|
|
||||||
lower: true,
|
|
||||||
accents: false,
|
|
||||||
punctuation: false,
|
|
||||||
symbols: 'split',
|
|
||||||
limit: 50,
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
@ -1,3 +1,75 @@
|
||||||
import slugify from '../../common/slugify.cjs';
|
const substitutes = {
|
||||||
|
à: 'a',
|
||||||
|
á: 'a',
|
||||||
|
ä: 'a',
|
||||||
|
å: 'a',
|
||||||
|
ã: 'a',
|
||||||
|
æ: 'ae',
|
||||||
|
ç: 'c',
|
||||||
|
è: 'e',
|
||||||
|
é: 'e',
|
||||||
|
ë: 'e',
|
||||||
|
ẽ: 'e',
|
||||||
|
ì: 'i',
|
||||||
|
í: 'i',
|
||||||
|
ï: 'i',
|
||||||
|
ĩ: 'i',
|
||||||
|
ǹ: 'n',
|
||||||
|
ń: 'n',
|
||||||
|
ñ: 'n',
|
||||||
|
ò: 'o',
|
||||||
|
ó: 'o',
|
||||||
|
ö: 'o',
|
||||||
|
õ: 'o',
|
||||||
|
ø: 'o',
|
||||||
|
œ: 'oe',
|
||||||
|
ß: 'ss',
|
||||||
|
ù: 'u',
|
||||||
|
ú: 'u',
|
||||||
|
ü: 'u',
|
||||||
|
ũ: 'u',
|
||||||
|
ỳ: 'y',
|
||||||
|
ý: 'y',
|
||||||
|
ÿ: 'y',
|
||||||
|
ỹ: 'y',
|
||||||
|
};
|
||||||
|
|
||||||
export default slugify;
|
export default function slugify(strings, delimiter = '-', {
|
||||||
|
encode = false,
|
||||||
|
removeAccents = true,
|
||||||
|
removePunctuation = false,
|
||||||
|
limit = 1000,
|
||||||
|
} = {}) {
|
||||||
|
if (!strings || (typeof strings !== 'string' && !Array.isArray(strings))) {
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
const slugComponents = []
|
||||||
|
.concat(strings)
|
||||||
|
.filter(Boolean)
|
||||||
|
.flatMap((string) => string
|
||||||
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(removePunctuation && /[.,:;'"_-]/g, '')
|
||||||
|
.match(/[A-Za-zÀ-ÖØ-öø-ÿ0-9]+/g));
|
||||||
|
|
||||||
|
if (!slugComponents) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const slug = slugComponents.reduce((acc, component, index) => {
|
||||||
|
const accSlug = `${acc}${index > 0 ? delimiter : ''}${component}`;
|
||||||
|
|
||||||
|
if (accSlug.length < limit) {
|
||||||
|
if (removeAccents) {
|
||||||
|
return accSlug.replace(/[à-ÿ]/g, (match) => substitutes[match] || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return accSlug;
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, '');
|
||||||
|
|
||||||
|
return encode ? encodeURI(slug) : slug;
|
||||||
|
}
|
||||||
|
|
|
||||||
2
static
2
static
|
|
@ -1 +1 @@
|
||||||
Subproject commit 50a262da611d6435a0bf77662f47d0a9126615f0
|
Subproject commit c3a287bfae05a7bb92d028c4036ec418b7efe5c5
|
||||||
Loading…
Reference in New Issue