Reject URLs with empty host, consolidate validation#19
Conversation
The scheme-only check accepted "https://" and "http:///path" because url.Parse sets a non-empty Scheme with an empty Host. Guard on Host == "" so bare schemes can no longer slip into the database. While rewriting: drop the redundant url.ParseRequestURI pre-check (the Parse + scheme + host test covers every case already), and extract a single validateHTTPURL helper used for both the blog URL and feed URL. Adds unit cases for the new gap and an e2e test that exercises the add command with invalid URLs in both flag and env modes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Follow-up to #18 — closes a validation gap and cleans up the implementation.
https://andhttp:///pathwere accepted becauseurl.Parsereturns a non-emptySchemewith emptyHost. Adds aparsed.Host == ""guard so bare schemes are rejected.url.ParseRequestURIpre-check (theParse+ scheme + host test covers every case in the existing table), and extracted a singlevalidateHTTPURLhelper used for both the blog URL and the feed URL.Test plan
TestAddBlogInvalidURL:https://,http:///path, feedhttps://.TestAddBlogInvalidURLexercises theaddcommand end-to-end in bothflagsandenvmodes with four invalid inputs, assertingInvalid URLon stderr.golangci-lint run ./...— clean.gotestsum ./...— 106 tests pass.🤖 Generated with Claude Code