当我尝试使用本机
URL
API 进行验证时,令人惊讶的是,Edge 浏览器的行为有所不同。所以输入:
const myUrlString = "abfss://myprojectname/filename.csv";
const myUrl = new URL(myUrlString);
console.log(myUrl);
注:
abfss://
是微软的Azure文件存储协议。
Chrome 回归:
{
"hash": "",
"host": "myprojectname",
"hostname": "myprojectname",
"href": "abfss://myprojectname/filename.csv",
"origin": "null",
"password": "",
"pathname": "/filename.csv",
"port": "",
"protocol": "abfss:",
"search": "",
"username: "",
...
}
边缘返回:
{
"hash": "",
"host": "",
"hostname": "",
"href": "abfss://myprojectname/filename.csv",
"origin": "null",
"password": "",
"pathname": "//myprojectname/filename.csv",
"port": "",
"protocol": "abfss:",
"search": "",
"username": "",
...
}
注意
host
和 hostname
是空字符串。
由于某种原因,它不会解析任何非 http(s)
协议的 URL。
有谁知道如何解决这个问题以使跨浏览器具有统一的行为?
const myUrlString = "abfss://myprojectname/filename.csv";
const myUrl = new URL(myUrlString);
console.log(myUrl);
{ “哈希”:“”, “主机”:“我的项目名称”, “主机名”:“我的项目名称”, "href": "abfss://myprojectname/filename.csv", “来源”:“空”, “密码”: ””, "路径名": "/文件名.csv", “港口”: ””, “协议”:“abfss:”, “搜索”: ””, “用户名:”, ... }