use replaceAll for dehyphenation#4340
use replaceAll for dehyphenation#4340jenul-ferdinand wants to merge 1 commit intoSSWConsulting:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the dehyphenateUrl function where only the first hyphen was being replaced instead of all hyphens. The fix changes replace() to replaceAll() to correctly handle presenter names with multiple hyphens in URL parameters.
- Updated
dehyphenateUrlto usereplaceAll()instead ofreplace()for complete hyphen replacement
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| @@ -1,3 +1,3 @@ | |||
| export const dehyphenateUrl = (name: string) => { | |||
| return name.replace("-", " "); | |||
| return name.replaceAll("-", " "); | |||
There was a problem hiding this comment.
The fix for dehyphenateUrl should include test coverage to verify that all hyphens are replaced correctly. Consider adding tests that cover:
- Single hyphen:
"foo-bar"→"foo bar" - Multiple hyphens:
"foo-bar-baz"→"foo bar baz" - No hyphens:
"foobar"→"foobar" - Edge cases: empty string, string with only hyphens, etc.
This would prevent regression of the original bug where only the first hyphen was replaced.
This fixes an issue with the dehyphenateUrl function, which previously only replaces the first hyphen in a string. For URLs with multiple hyphens (e.g.,
foo-bar-foo), would incorrectly returnfoo bar-foo.The fix was to use
replaceAll()instead ofreplace().