diff --git a/src/actors.js b/actors.js similarity index 100% rename from src/actors.js rename to actors.js diff --git a/package.json b/package.json index 12e43c1..0217a50 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "traxxx-utils", + "name": "traxxx-common", "version": "1.1.3", "description": "Common utilities for traxxx core and web.", "main": "src/app.js", diff --git a/src/slugify.js b/src/slugify.js deleted file mode 100755 index ca0a323..0000000 --- a/src/slugify.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -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;