Skip to content

🧹 Janitor: Remove magic number slicing in URL normalization#168

Merged
lucasew merged 1 commit into
masterfrom
janitor-remove-magic-numbers-13148102702252826725
Jul 5, 2026
Merged

🧹 Janitor: Remove magic number slicing in URL normalization#168
lucasew merged 1 commit into
masterfrom
janitor-remove-magic-numbers-13148102702252826725

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Assumptions

  • strings.TrimPrefix is the appropriate standard library function to use here.
  • The normalizeAndValidateURL function is already tested, and those tests continue to pass.

Alternatives Not Chosen

  • Keeping the magic numbers: This is bad practice and less readable.

How To Pivot

  • If there are performance concerns with 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

  • Apply strings.TrimPrefix to other similar string manipulations in the codebase if they exist.
  • Standardize on net/url parsing 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

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.
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
articleparser Ready Ready Preview, Comment Jul 5, 2026 5:12am

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@lucasew lucasew marked this pull request as ready for review July 5, 2026 11:16
@lucasew lucasew merged commit 11f9311 into master Jul 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant