2 Star 0 Fork 0

mirrors_webcomponents/URL

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
urltestrunner.html 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
<!doctype html>
<base id=base>
<meta charset=utf-8>
<script>forceJURL = true</script>
<script src=url.js></script>
<script src=urltestparser.js></script>
<script>
function fetchTests() {
var request = new XMLHttpRequest()
request.open("GET", "urltests.txt")
request.send()
request.responseType = "text"
request.onload = function() { runTests(request.response) }
}
function setBase(base) {
document.getElementById("base").href = base
}
function bURL(url, base) {
base = base || "about:blank"
setBase(base)
var a = document.createElement("a")
a.setAttribute("href", url)
return a
}
function runTests(raw) {
var tests = URLTestParser(raw)
for(var i = 0, l = tests.length; i < l; i++) {
var test = tests[i],
url = new URL(test.input, new URL(test.base))
if(url.protocol != test.protocol ||
url.hostname != test.host ||
url.port != test.port ||
url.pathname != test.path ||
url.search != test.search ||
url.hash != test.hash ||
url.href != test.href) {
document.querySelector("pre").appendChild(document.createTextNode("Got: " + url.protocol + "," + url.hostname + "," + url.port + "," + url.pathname + "," + url.search + "," + url.hash + ", expected: " + test.href + ", for input:" + test.input + "\n"))
}
/*
url = bURL(test.input, test.base)
if(url.protocol != test.protocol ||
url.hostname != test.host ||
url.port != test.port ||
url.pathname != test.path ||
url.search != test.search ||
url.hash != test.hash ||
url.href != test.href) {
document.querySelector("pre").appendChild(document.createTextNode("BROWSER Got: " + url.protocol + "," + url.hostname + "," + url.port + "," + url.pathname + "," + url.search + "," + url.hash + ", expected: " + test.href + ", for input:" + test.input + "\n"))
}
*/
}
document.querySelector("pre").appendChild(document.createTextNode("DONE"))
}
window.onload = fetchTests
</script><pre>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_webcomponents/URL.git
git@gitee.com:mirrors_webcomponents/URL.git
mirrors_webcomponents
URL
URL
master

搜索帮助