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>
@bensenescu

Copy link
Copy Markdown
Contributor

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:
https://openseo.so/roadmap

Contributing through Issues
Right now, the best way to contribute is through creating quality "Issues" which are easier for me to review and prioritize right now.

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 /simple-issue-description skill described in the guide to convert the PR to an issue.

@Arunendra21

Copy link
Copy Markdown
Author

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!

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.

2 participants