Skip to content

apply: re-strip trailing hyphen after slice so slugify is idempotent#3

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1777491014-apply-slugify-idempotent
Open

apply: re-strip trailing hyphen after slice so slugify is idempotent#3
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1777491014-apply-slugify-idempotent

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 29, 2026

Summary

Devin Review caught a real edge case in slugify on components/sections/apply-form.tsx.slice(0, 32) runs after .replace(/^-+|-+$/g, ""), so when the 32-char cap landed on a hyphen the truncation reintroduced the trailing hyphen the prior strip had removed.

That made slugify non-idempotent: slugify(slugify(x)) could differ from slugify(x). The form's advance check on the slug step is state.slug === slugify(state.slug) (the input value is already slugify(raw) because of onChange={(e) => update("slug", slugify(e.target.value))}), so the user's slug fails the round-trip and the form blocks them — with a misleading "Slug must be lowercase letters, numbers, and hyphens only" error.

Repro: type "abcdefghijklmnopqrstuvwxyz12345 xy" into the slug field. Without this PR it gets stored as "abcdefghijklmnopqrstuvwxyz12345-" (32 chars, trailing hyphen) and the Continue button stays disabled with the wrong error.

Fix is one line: re-strip a trailing hyphen after the slice cap.

Review & Testing Checklist for Human

  • Open the Vercel preview's /apply form, get to the slug step, paste a long name with a space at character 31 (e.g. "abcdefghijklmnopqrstuvwxyz12345 xy"), confirm the slug ends without a trailing - and the Continue button enables.
  • Sanity-check normal inputs ("Ada Lovelace""ada-lovelace") still slugify correctly.

Notes

  • One-line behavioural change inside the slugify pipeline. No type changes, no new tests added (the form is exercised end-to-end in the preview).
  • Build green locally (pnpm build).

Link to Devin session: https://app.devin.ai/sessions/091fc09f81b5489292102ebcdc173dbb
Requested by: @DearMrFree


Open in Devin Review

Devin Review #BUG_..._0001: when an input long enough to hit the 32-char cap
landed with a hyphen at character 32, .slice(0, 32) reintroduced the trailing
hyphen the prior .replace(/^-+|-+$/g, '') had stripped. That made slugify
non-idempotent — slugify(slugify(x)) != slugify(x) — which silently broke
the state.slug === slugify(state.slug) advance check on the slug step and
showed a misleading 'invalid characters' error. One-line fix: re-strip a
trailing hyphen after the slice.
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sofai Ready Ready Preview, Comment Apr 29, 2026 7:32pm

Copy link
Copy Markdown
Contributor Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

devin-ai-integration Bot added a commit that referenced this pull request Apr 30, 2026
…out resolveNext

Mirrors sof-ai-repo PR #55 follow-up. WHATWG URL parser normalises
backslashes to forward slashes for http/https, so '/\\evil.com'
resolves to 'https://evil.com/' — open redirect via Location header.

Co-Authored-By: Dr. Freedom Cheteni <freedom@thevrschool.org>
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