Skip to content

fix: keep org slugs free of trailing dashes after truncation - #189

Open
Arunendra21 wants to merge 1 commit into
every-app:mainfrom
Arunendra21:fix-org-slug-trailing-dash
Open

fix: keep org slugs free of trailing dashes after truncation#189
Arunendra21 wants to merge 1 commit into
every-app:mainfrom
Arunendra21:fix-org-slug-trailing-dash

Conversation

@Arunendra21

Copy link
Copy Markdown

What: Fixes a bug in slugify (src/server/auth/org-slug.ts).

slugify stripped leading and trailing dashes before truncating the value to 48 characters. When the 48 character cut lands on a - separator, the final slug still ends with a dash, which is exactly what the trailing-dash strip is meant to prevent.

For example, a long organization name can produce a slug like my-really-long-org-name-that-goes-on- (trailing dash), and in default-hosted-organization.ts that becomes ...goes-on--<suffix> with a double dash once the suffix is appended.

Fix: truncate to 48 characters first, then strip leading and trailing dashes, so the slug never keeps a stray dash on either end. Normal inputs are unchanged.

Testing: added src/server/auth/org-slug.test.ts with vitest cases for normal values, edge trimming, the empty fallback, the truncation-on-separator case, and toHex.

slugify stripped leading and trailing dashes before truncating to 48
characters, so when the 48 character cut landed on a "-" separator the
final slug still ended with a dash. For example a long organization name
could produce a slug like "my-org-", which then became "my-org--suffix"
once the suffix was appended in default-hosted-organization.ts.

Truncate first and strip the dashes afterwards so the slug never keeps a
leading or trailing dash. Normal inputs are unchanged.

Adds unit tests for slugify and toHex.

Co-authored-by: eeshsaxena <eeshsaxena@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant