Skip to content

[Bug] 内置浏览器输 localhost:3000(不带 http://)打不开 #1095

Description

@yuxino

What happened? / 问题描述

内置浏览器地址栏输 localhost:3000 打不开,点了没反应。加上 http:// 就能开。

Steps to reproduce / 复现步骤

  1. 在内置浏览器地址栏输入 localhost:3000(或 localhost:3000/index.html),按回车
  2. 没有任何反应

Expected behavior / 预期行为

像 example.com 那样,自动补上 http:// 打开。

Actual behavior / 实际行为

什么都不发生,不报错也不提示。

哪些行、哪些不行

地址栏里输的 结果
localhost:3000 打不开
localhost:3000/index.html 打不开
example.com:8080 打不开
127.0.0.1:3000 能开(自动补成 http://127.0.0.1:3000)
example.com 能开(自动补成 http://example.com/)
http://localhost:3000/index.html 能开

规律是:以字母开头、又带冒号的输入,会被当成"已经写了协议头",于是 localhost: 被误认成协议名。127.0.0.1 以数字开头,所以躲过去了。而本地开发服务器基本都是 localhost:3000 这种写法。

另外 apps/desktop/electron/main/browser-view.ts 里 resolveLocalFile() 的注释写着 localhost:3000/a.html 会"落到 URL 处理,而不是一次坏掉的文件加载",实际并不会,注释也过时了。

App version / 应用版本

0.15.8

Operating system / 操作系统

macOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions