import { urlHelper } from "https://deno.land/x/m_utils@v1.0.5/mod.ts";
const { parseUrl } = urlHelper;
解析url返回解析后的对象
Examples
解析url及参数
解析url及参数
const obj: TUrl = urlHelper.parseUrl('http://www.baidu.com/a?a=1&b=1&c=1.0&d=111')
// output
[Object: null prototype] {
origin: "http://www.baidu.com",
protocol: "http:",
host: "www.baidu.com",
pathname: "/a",
hash: "",
params: [Object: null prototype] { a: "1", b: "1", c: "1.0", d: "111" }
}
const obj1: TUrl = urlHelper.parseUrl('http://www.baidu.com/#/a?a=1&b=1&c=1.0&d=111')
// output
[Object: null prototype] {
origin: "http://www.baidu.com",
protocol: "http:",
host: "www.baidu.com",
pathname: "/",
hash: "#/a",
params: [Object: null prototype] { a: "1", b: "1", c: "1.0", d: "111" }
}
const obj2: TUrl = urlHelper.parseUrl('a')
if (obj2 && obj2.params) {
console.log(obj2.params['a']);
}
// output
{}