fix: keep org slugs free of trailing dashes after truncation - #189
fix: keep org slugs free of trailing dashes after truncation#189Arunendra21 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>
|
Hey, Thanks for contributing! For the next few months, I'm going to stop accepting external PRs. Reviewing and testing them has been slowing down progress against our roadmap: Contributing through Issues Here is our updated contributing guide: https://github.com/every-app/open-seo/blob/main/docs/CONTRIBUTING.md Converting, this PR to an issue would be the best way to get it prioritized. You can use the the |
|
Thanks for the heads-up, and no worries at all — completely understand wanting to keep the roadmap moving. Happy to refile this as an Issue following the contributing guide if that is the more useful path right now. Appreciate the work on open-seo! |
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.