Skip to content

Reject URLs with empty host, consolidate validation#19

Merged
JulienTant merged 1 commit intomainfrom
fix/url-host-validation
Apr 22, 2026
Merged

Reject URLs with empty host, consolidate validation#19
JulienTant merged 1 commit intomainfrom
fix/url-host-validation

Conversation

@JulienTant
Copy link
Copy Markdown
Owner

Summary

Follow-up to #18 — closes a validation gap and cleans up the implementation.

  • Correctness: https:// and http:///path were accepted because url.Parse returns a non-empty Scheme with empty Host. Adds a parsed.Host == "" guard so bare schemes are rejected.
  • Cleanup: dropped the redundant url.ParseRequestURI pre-check (the Parse + scheme + host test covers every case in the existing table), and extracted a single validateHTTPURL helper used for both the blog URL and the feed URL.

Test plan

  • New unit cases in TestAddBlogInvalidURL: https://, http:///path, feed https://.
  • New e2e test TestAddBlogInvalidURL exercises the add command end-to-end in both flags and env modes with four invalid inputs, asserting Invalid URL on stderr.
  • golangci-lint run ./... — clean.
  • gotestsum ./... — 106 tests pass.

🤖 Generated with Claude Code

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@JulienTant has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 45 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0653995f-b411-4c59-8ca4-627c56f96cce

📥 Commits

Reviewing files that changed from the base of the PR and between 24759df and 282f0ec.

📒 Files selected for processing (3)
  • e2e/e2e_test.go
  • internal/controller/controller.go
  • internal/controller/controller_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/url-host-validation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JulienTant JulienTant merged commit 0022ee4 into main Apr 22, 2026
2 checks passed
@JulienTant JulienTant deleted the fix/url-host-validation branch April 22, 2026 03:50
@JulienTant JulienTant mentioned this pull request Apr 22, 2026
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