Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Latest
function parseUrl
import { parseUrl } from "https://deno.land/x/m_utils@v1.0.5/src/url.ts";

解析url返回解析后的对象

Examples

解析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
{}

Parameters

url: string

生成数据的长度n

Returns

n位数对应的最大值和最小值