Repository navigation
fix(desktop): allow valid git characters in branch name sanitization #1470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,10 +2,13 @@ export function sanitizeSegment(text: string, maxLength = 50): string { | |||||
| return text | ||||||
| .toLowerCase() | ||||||
| .trim() | ||||||
| .replace(/[^a-z0-9\s-]/g, "") | ||||||
| .replace(/\s+/g, "-") | ||||||
| .replace(/[^a-z0-9._+@-]/g, "") | ||||||
| .replace(/\.{2,}/g, ".") | ||||||
| .replace(/@\{/g, "@") | ||||||
| .replace(/-+/g, "-") | ||||||
| .replace(/^-|-$/g, "") | ||||||
| .replace(/^[-.]|[-.]+$/g, "") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leading-character strip only removes a single
Suggested fix- .replace(/^[-.]|[-.]+$/g, "")
+ .replace(/^[-.]+|[-.]+$/g, "")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| .replace(/\.lock$/g, "") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repeated A single Suggested fix- .replace(/\.lock$/g, "")
+ .replace(/(\.lock)+$/g, "")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| .slice(0, maxLength); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@{replacement on line 8 is dead code —{is already stripped by line 6.The allowlist on line 6 (
[^a-z0-9._+@-]) does not include{, so{is removed before the@{replacement on line 8 ever runs. For example,"test@{0}"becomes"test@0"at line 6 already.The test still passes because line 6 handles it, but line 8 is unreachable. Either remove line 8 or reorder lines 7-8 before line 6 so the
@{→@normalization runs on the original input first.Suggested fix: remove the dead line
.replace(/[^a-z0-9._+@-]/g, "") .replace(/\.{2,}/g, ".") - .replace(/@\{/g, "@") .replace(/-+/g, "-")🤖 Prompt for AI Agents