From b844fd489d1b3464fcc0898c70943df5367b4fd3 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" Date: Wed, 29 Apr 2026 19:31:26 +0000 Subject: [PATCH] apply: re-strip trailing hyphen after slice cap so slugify is idempotent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- components/sections/apply-form.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/sections/apply-form.tsx b/components/sections/apply-form.tsx index 3936aab..b31b784 100644 --- a/components/sections/apply-form.tsx +++ b/components/sections/apply-form.tsx @@ -33,6 +33,11 @@ const slugify = (s: string): string => .replace(/[^a-z0-9]+/g, "-") .replace(/^-+|-+$/g, "") .slice(0, 32) + // Re-strip a trailing hyphen if the 32-char cap landed on one. Without + // this second pass, slugify is non-idempotent — `slugify(slugify(x))` + // can differ from `slugify(x)`, which silently breaks the + // `state.slug === slugify(state.slug)` advance check below. + .replace(/-+$/g, "") export function ApplyForm() { const [state, setState] = useState({