Compare commits
No commits in common. "41e9e0d85e58a4f1c4c56baa5dea3f97f437a37e" and "947b56148dfbf2e4b75b5294de3446e2001c55ff" have entirely different histories.
41e9e0d85e
...
947b56148d
2
common
2
common
|
|
@ -1 +1 @@
|
||||||
Subproject commit ee23dc0358677a66b27a20b8d56c4b69782cec9b
|
Subproject commit c45852d6937abe25e1205af0b9b96d49970901c8
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.245.3",
|
"version": "1.245.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.245.3",
|
"version": "1.245.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.458.0",
|
"@aws-sdk/client-s3": "^3.458.0",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.245.3",
|
"version": "1.245.2",
|
||||||
"description": "All the latest porn releases in one place",
|
"description": "All the latest porn releases in one place",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const slugify = require('../utils/slugify');
|
|
||||||
|
|
||||||
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,5 +1,79 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const slugify = require('../../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',
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = slugify;
|
module.exports = slugify;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue