fix: keep org slugs free of trailing dashes after truncation - #189
Open
Arunendra21 wants to merge 1 commit into
Open
fix: keep org slugs free of trailing dashes after truncation#189Arunendra21 wants to merge 1 commit into
Arunendra21 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Fixes a bug in
slugify(src/server/auth/org-slug.ts).slugifystripped 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 indefault-hosted-organization.tsthat 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.tswith vitest cases for normal values, edge trimming, the empty fallback, the truncation-on-separator case, andtoHex.