🧹 Janitor: Remove magic number slicing in URL normalization#168
Conversation
Replaced hardcoded string slicing (rawLink[6:] and rawLink[7:]) with strings.TrimPrefix in api/index.go. This makes the intent clearer and avoids potential out-of-bounds panics if the logic surrounding the string prefixes were to change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Assumptions
strings.TrimPrefixis the appropriate standard library function to use here.normalizeAndValidateURLfunction is already tested, and those tests continue to pass.Alternatives Not Chosen
How To Pivot
strings.TrimPrefix, we could revert back to slicing, but given this is just URL parsing, the overhead is negligible and the readability improvement is worth it.Next Knobs
strings.TrimPrefixto other similar string manipulations in the codebase if they exist.net/urlparsing rather than manual string manipulation where possible.I have verified the change visually and by running the tests using
mise run test. No new errors were introduced.PR created automatically by Jules for task 13148102702252826725 started by @lucasew