Skip to content

bug: slugify deletes non-ASCII letters instead of transliterating them #760

Closed

Description

@gkhngyk

Description

slugify throws away every character outside a-z0-9-:

.replace(/[^a-z0-9-]/g, '')

Accented and non-ASCII letters are not transliterated, they are deleted. For a product whose brands are often Turkish, that hollows the name out rather than shortening it:

Name Slug produced
Ürün rn
Şeker eker
Çiğdem idem
Öz Güven z-gven
Ağaç aa

The same applies to German, French, Nordic and Slavic names — Müller becomes mller.

Nothing routes on the slug, so this breaks no navigation. Where it shows up is filenames: every CSV and PDF export is named ansvisor_${slug}_…, so a brand exports as ansvisor_rn_prompts_2026-08-21.csv. It also collides more eagerly than it should — Ağaç and Aa produce the same slug.

There are three copies of this logic, and they have already drifted apart in their fallbacks:

Steps to reproduce

  1. Create a brand named Ürün.
  2. Look at its slug, or export any CSV from one of its pages.

Expected behavior

The slug carries the name across: urun. Exports read ansvisor_urun_prompts_….csv.

Actual behavior

The slug is rn, and exports read ansvisor_rn_prompts_….csv.

Deployment mode

Cloud (ansvisor.com)

Environment

Not environment-specific.

Notes for whoever picks this up

Transliterate before stripping. The tidy way is Unicode normalization — normalize('NFD') splits a letter from its accent so the accent can be removed on its own, which handles é → e, ü → u and most of Latin-1 without a lookup table.

Two Turkish letters do not decompose and need an explicit mapping: ı and ş, plus ğ. Handle those before or alongside the normalization pass, and take care with I/ı — lowercasing Turkish is famously not the same as lowercasing English, so test Işık explicitly.

Please also pull the three copies into one shared helper while you are in there. Three implementations of the same rule is how they drifted in the first place; a single one with tests is the real fix. There is no test file for it today — a new one alongside web/src/lib/csv.test.ts is the pattern to follow.

Do not backfill existing rows. Slugs are stored, and rewriting them is a separate decision with its own consequences. This issue is about what new names produce.

Activity

  1. added
    bug
    good first issue
    help wanted
    on Aug 21, 2026
  2. shahzainshafique commented on Aug 21, 2026

    @shahzainshafique
    Contributor

    Hi @gkhngyk, I am picking up this issue.

  3. gkhngyk commented on Aug 21, 2026

    @gkhngyk
    ContributorAuthor

    @shahzainshafique it's yours — go ahead.

    Two things from the issue worth repeating, since they are what makes this more than a one-line change:

    • One shared helper, not three. Replace the copies in brand.ts, organization.ts and the inline chain in onboarding/page.tsx, keeping each call site's existing fallback prefix (brand-, org-).
    • Cover ı, ş and ğ explicitly — they don't decompose under NFD — and test Işık for the Turkish lowercase case.

    No backfill of existing slugs.

  4. added a commit that references this issue on Aug 21, 2026
    c475bec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buggood first issuehelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions