Skip to content

[Bug] slugify drops uppercase accented letters and keeps backslashes in slugs #85

Open

Description

@trackoor

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:

  1. 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.
  2. 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"));
EOF

Expected 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/utils 0.30.1 (latest), also reproduced on main (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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions