Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url #53

Open
Genluo opened this issue Sep 6, 2019 · 0 comments
Open

url #53

Genluo opened this issue Sep 6, 2019 · 0 comments
Labels
Node Node相关

Comments

@Genluo
Copy link
Owner

Genluo commented Sep 6, 2019

url模块用于处理与解析URL,url模块提供两套API来处理URL:一个是旧版本遗留的API,一个是实现WHATWG标准的新的API,两者的区别如下:

  • 上方是遗留的url.parse返回的对象属性url.parse()
  • 下方是WHATWG的URL对象的属性new URL()

文档部分

  • URL类
    • new URL(input[, base]):input是相对URL,base为要解析的基本URL
      • 属性
        • … 有些属性参照上图
        • searchParams:获取URLSearchParams类的实例
      • 方法
        • toString()
        • toJSON()
  • URLSearchParams
    • new URLSearchParams(string):将string解析成一个查询字符串
    • new URLSearchParams(obj):将一个对象每个属性和值转化为字符串
    • new URLSearchParams(iterable):将一个具有迭代接口转化为字符串
      • 方法
        • append(name, value)
        • delete(name)
        • entries()
        • forEach(fn, [, thisArg])
        • get(name)
        • getAll(name)
        • has(name)
        • keys()
        • set(name, value)
        • sort()
        • toString()
        • values()
  • 模块属性
    • domainToASCII(domain)
    • domainToUnicode(domain)
    • fileURLToPath(url):将fileUrl转化为路径
    • format(URL[, options]):返回一个WHATWG URL对象的可自定义的URL字符串表达式
    • pathToFileURL(path):将文件路径转化为file协议的路径
@Genluo Genluo added the Node Node相关 label Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Node Node相关
Projects
None yet
Development

No branches or pull requests

1 participant