fix: Transform # character to - in slug#10896
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@ujwalkumar1995 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for following the naming conventions! 🙏 |
| .replace(/[\s_#]+/g, "-") // Replace whitespace, # and underscores with a single dash | ||
| .replace(/^-+/, "") // Remove dashes from start | ||
| .replace(/-+$/, "") // Remove dashes from end | ||
| .replace(/\+/g, "-"); // Transform all + to - |
There was a problem hiding this comment.
This was not required as + was already being replaced as part of 'Replace any non-alphanumeric characters (including Unicode) with a dash' regex.
Have verified and added tests for it.
| @@ -5,10 +5,9 @@ export const slugify = (str: string) => { | |||
| .normalize("NFD") // Normalize to decomposed form for handling accents | |||
| .replace(/\p{Diacritic}/gu, "") // Remove any diacritics (accents) from characters | |||
| .replace(/[^\p{L}\p{N}\p{Zs}\p{Emoji}]+/gu, "-") // Replace any non-alphanumeric characters (including Unicode) with a dash | |||
There was a problem hiding this comment.
I verified this regex, it should not have ideally allowed # character. I am not sure why it is doing so. Therefore had to add an explicit check to replace # character
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Udit-takkar
left a comment
There was a problem hiding this comment.
LGTM. works fine now
What does this PR do?
In slugs, # character was not being replaced by - which could lead to 404 page not found. Fixed this issue as part of this PR.
Fixes #10443
Recording.2023-08-23.014832.mp4
Requirement/Documentation
Type of change
How should this be tested?
Try to create an event type with # in the name. # will be replaced by -.
Mandatory Tasks
Checklist
I noticed couple of things as part of this change. Have added my observations as comments in the PR review section for better understanding.