Skip to content

fix: support single-label URL hosts - #30

Merged
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/support-single-label-url-host
Aug 28, 2026
Merged

fix: support single-label URL hosts#30
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/support-single-label-url-host

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 28, 2026

Copy link
Copy Markdown

Summary

  • accept single-label registered names such as fastapi in URL validation
  • keep the existing protocol, authentication, IP, port, path, and fully qualified domain handling
  • retain rejection coverage for invalid labels that start with a hyphen

Background

The current expression requires every non-localhost registered name to end in a dotted TLD. That rejects internal service URLs such as http://fastapi:3000/mcp, even though RFC 3986 defines a host as an IP literal, IPv4 address, or registered name and does not require every registered name to be globally DNS-qualified.

This keeps the existing host-label expression and only makes the domain-plus-TLD suffix optional. It does not replace the validator with the broader platform URL parser.

Closes #19.

Validation

Exact head: e21da4a

  • base/head regression: the new single-label case fails on master and passes on this head
  • focused URL suite: 12/12 tests passed
  • full suite: 16/16 suites, 116/116 tests, 8/8 snapshots passed
  • TypeScript: passed
  • package compilation: passed
  • ESLint: 0 errors, 3 pre-existing unrelated warnings
  • Prettier: passed
  • git diff --check: passed

AI assistance disclosure

Codex was used to trace the URL grammar, search for overlapping work, implement the focused change and regressions, run base/head and full validation, and draft this description. I verified the source diff and all reported results.

Summary by CodeRabbit

  • Bug Fixes
    • URL 校验现在支持不带域名后缀的单标签主机名,例如 http://fastapi:3000/mcp
    • 继续拒绝以连字符开头等格式无效的主机名,并提供相应校验错误。

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9833c9f3-f1de-44e1-be2f-19a159653a0f

📥 Commits

Reviewing files that changed from the base of the PR and between 44f8f27 and e21da4a.

📒 Files selected for processing (2)
  • src/rule/url.ts
  • tests/url.spec.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

URL 规则现在允许单标签主机名,例如 fastapi。新增测试验证有效主机名通过校验,并验证以连字符开头的主机名仍被拒绝。

Changes

单标签主机名 URL 校验

Layer / File(s) Summary
放宽主机名匹配并补充校验测试
src/rule/url.ts, tests/url.spec.ts
URL 正则表达式将 domain 和 tld 组合设为可选。测试验证 http://fastapi:3000/mcp 通过,并验证 http://-fastapi:3000/mcp 返回 v is not a valid url

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to e21da

This localized change allows valid single-label URL hosts while preserving existing validation behavior, with passing regression and full-suite checks; no actionable merge-blocking risk remains.

Poem

小兔打开 URL 门,
fastapi 主机名顺利进。
连字符开头被拦下,
正则守住校验线。
测试轻轻点头笑。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: support single-label URL hosts”准确概括了本次对单标签 URL 主机名的支持,内容简洁且明确。
Linked Issues check ✅ Passed 变更满足直接关联问题 #19 的目标:允许校验 http://fastapi:3000/mcp 这类单标签主机名 URL,同时继续拒绝以连字符开头的无效主机名。实现和回归测试均覆盖了该要求。
Out of Scope Changes check ✅ Passed 变更仅修改 URL 正则表达式并新增对应测试,内容与问题 #19 和 PR 目标直接相关,未发现明显的范围外修改。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.38%. Comparing base (44f8f27) to head (e21da4a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #30   +/-   ##
=======================================
  Coverage   82.38%   82.38%           
=======================================
  Files          25       25           
  Lines         653      653           
  Branches      238      236    -2     
=======================================
  Hits          538      538           
  Misses        114      114           
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoyo837
yoyo837 merged commit 8cca839 into react-component:master Aug 28, 2026
8 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.

type = url 不支持 http://fastapi:3000 这种 docker 容器间通信的 url

2 participants