Skip to content

fix(browser): accept localhost and dotted hosts with ports - #1121

Merged
vastsa merged 4 commits into
vastsa:mainfrom
yuxino:fix/browser-schemeless-host-port
Sep 27, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
yuxino:fix/browser-schemeless-host-port

Conversation

@yuxino

@yuxino yuxino commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

问题与修复

地址栏把 localhost:3000、localhost:3000/index.html 和 example.com:8080 误判为自定义 scheme,主进程因此拒绝导航。现在仅把 localhost 或点分主机名加数字端口识别为省略协议的 HTTP 地址;file:、javascript: 和其他不支持的 scheme 仍走原有拒绝路径。同步更新了 resolveLocalFile() 注释、中英文浏览器规格和 E2E-059 场景。

验证

  • 回归测试先在旧实现上失败;最新候选的 11 项浏览器导航测试通过,包含带 workspace root 的 BrowserPane.navigateAndWait() 用户路径。
  • 候选 3888b11ab(目标主线 b14caaabe):pnpm build:js、桌面 typecheck、pnpm lint、pnpm docs:check、pnpm check:pr-base 和 pnpm test:e2e:boot 通过。
  • 此前本机完整桌面测试在旧基线上有 1 项 SSH 耗时断言失败、2 项 npm/SSH 超时取消;合入最新主线后尚未在本机重跑全套,PR CI 将验证当前候选。
  • E2E-059 是手工场景;本次未运行会操作桌面实例的 verify:ui:*。
  • 此前与 fix(browser): explain local file preview restrictions #1120 的 head 做了只读合并模拟,没有冲突标记;两项修复范围独立。

真实桌面录屏

同一本地页面:修复前输入 localhost:3000 失败,修复后自动补全为 http://localhost:3000/ 并加载。1920×1080 录屏来自两份独立数据目录的真实 PI-Desktop 窗口;等比缩放并用中性边框补足画幅,只裁掉操作前后的等待。视频拍摄于修复提交 978015a47;其后合入的主线未改浏览器导航代码,最新候选已通过上述检查。

issue-1095-before-after-1920x1080.mp4

Refs #1095

The browser treated localhost:3000 and dotted hosts with ports as custom
schemes, rejecting common preview addresses. Recognize those host and port
forms before applying the existing HTTP(S) allowlist.

Cover normalization and the BrowserPane navigation path while preserving
unsupported scheme rejection. Sync the browser UX and E2E scenario.
@yuxino
yuxino marked this pull request as draft September 26, 2026 18:58
The published draft branch predates the current upstream base. Integrate it without rewriting the shared branch so the pull request remains current and mergeable.
The browser URL contract and E2E scenario have Chinese counterparts. Keep
those counterparts aligned with the address-input behavior documented in
the fix, including localhost paths and dotted hosts with ports.
Bring the browser fix branch onto the current integration base before PR validation.
@yuxino
yuxino marked this pull request as ready for review September 27, 2026 06:07
@vastsa
vastsa merged commit 6acfdf2 into vastsa:main Sep 27, 2026
4 checks passed
@vastsa

vastsa commented Sep 27, 2026

Copy link
Copy Markdown
Owner

已独立核对并合并。#1121 在 browser-view.ts 的 scheme-less host:port 归一化处修复了 localhost:3000 和点分主机端口被误识别为 scheme 的根因;相关 BrowserPane 回归测试及中英文规格已同步。GitHub 必需检查全部通过,合并提交为 6acfdf2e。感谢贡献!

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.

2 participants