URL.parse(input[, base])


  • input <string> 要解析的绝对或相对输入URL。如果 input 是相对的,则需要 base。如果 input 是绝对的,则会忽略 base。如果 input 不是字符串,则会先进行 转换为字符串
  • base <string> 如果 input 不是绝对路径,则基于该 URL 进行解析。如果 base 不是字符串,则先执行 转换为字符串
  • 返回:<URL> | <null>

将字符串解析为 URL。如果提供了 base,它将用作解析非绝对 input URL 的基准 URL。如果参数无法解析为有效的 URL,则返回 null

【Parses a string as a URL. If base is provided, it will be used as the base URL for the purpose of resolving non-absolute input URLs. Returns null if the parameters can't be resolved to a valid URL.】