Repository navigation
Description
Description
slugify in @rebasepro/utils (packages/utils/src/strings.ts) transliterates a fixed lowercase list (ãàáäâẽèéëêìíïîõòóöôùúüûñç), strips non-word characters with /[^\w\\-]+/g, and only calls .toLowerCase() at the end. As a result:
- Uppercase accented letters are stripped instead of transliterated, so
"École normale"becomes"cole_normale"while"école normale"becomes"ecole_normale", and"ZÜRICH"becomes"zrich"while"Zürich"becomes"zurich". Other common Latin letters outside the fixed list (ß,å/Å,ø/Ø,æ/Æ) are also stripped. - In
/[^\w\\-]+/g,\\inside the character class matches a literal backslash rather than escaping-, leaving\in the returned slug (slugify("a\\b")returns"a\\b").
In addition to direct @rebasepro/utils callers, cleanPropertiesFromImport and buildHeadersMappingFromData in @rebasepro/cms pass imported CSV/JSON column headers through slugify, so capitalized headers such as École or Índice become cole and ndice instead of matching or creating ecole and indice.
Steps to Reproduce
npm install @rebasepro/[email protected]
node --input-type=module << 'EOF'
import { slugify } from "@rebasepro/utils";
console.log(slugify("école normale"));
console.log(slugify("École normale"));
console.log(slugify("Zürich"));
console.log(slugify("ZÜRICH"));
console.log(slugify("Ñandú"));
console.log(slugify("Straße"));
console.log(slugify("Åland"));
console.log(slugify("a\\b"));
EOFExpected Behavior
Uppercase and lowercase forms produce matching ASCII slugs (and preserve case when lowercase = false, e.g. slugify("École", "_", false) -> "Ecole"), common Latin letters are transliterated rather than dropped, and backslashes are stripped:
ecole_normale
ecole_normale
zurich
zurich
nandu
strasse
aland
ab
Actual Behavior
ecole_normale
cole_normale
zurich
zrich
andu
strae
land
a\b
Screenshots
Not applicable.
Environment
- Rebase version:
@rebasepro/utils0.30.1 (latest), also reproduced onmain(e574ee5) - Node.js version: v26.13.0
- Database: Not applicable
- OS: Debian GNU/Linux 12 (bookworm)
- Browser (if applicable): Not applicable
Additional Context
packages/utils/test/strings.test.ts currently only tests lowercase accents (slugify("ãàáäâẽèéëê", "-")). Normalizing with NFD and stripping \p{Diacritic} (plus multi-character/stroke mappings such as ß -> ss, æ -> ae, ø -> o) before removing /[^\w-]+/g handles both cases.
Credit: https://ucsbplse.github.io/
Activity