将输入的字符串使用正则匹配,模拟返回window.location的值
<script src="./KLocation.js"></script>
or
npm install klocation
KLocation("https://github.com?a=1&b=2")
/*Objcet{
url:"https://github.com?a=1&b=2",
host : "github.com",
protocol : "https:",
pathname : "/",
port : ''
hostname : "github.com"
}*/
获取url参数集合返回一个对象
KLocation(url).getParam()
// 返回值
// {a:1,b:2}
获取url对应host
KLocation(url).getHost()
// 返回值
// github.com
获取url对应协议
KLocation(url).getProtocol()
// 返回值
// https:
获取url对应端口
KLocation(url).getPort()
// 返回值
// ''
获取url对应pathname
KLocation(url).getPathname()
// 返回值
// "/"