url.format()

url.format(urlObj)

Take a parsed URL object, and return a formatted URL string.

Here's how the formatting process works:

  • href will be ignored.
  • path will be ignored.
  • protocol is treated the same with or without the trailing : (colon).
    • The protocols http, https, ftp, gopher, file will be postfixed with :// (colon-slash-slash) as long as host/hostname are present.
    • All other protocols mailto, xmpp, aim, sftp, foo, etc will be postfixed with : (colon).
  • slashes set to true if the protocol requires :// (colon-slash-slash)
    • Only needs to be set for protocols not previously listed as requiring slashes, such as mongodb://localhost:8000/, or if host/hostname are absent.
  • auth will be used if present.
  • hostname will only be used if host is absent.
  • port will only be used if host is absent.
  • host will be used in place of hostname and port.
  • pathname is treated the same with or without the leading / (slash).
  • query (object; see querystring) will only be used if search is absent.
  • search will be used in place of query.
    • It is treated the same with or without the leading ? (question mark).
  • hash is treated the same with or without the leading # (pound sign, anchor).
doc_Nodejs
2016-04-30 04:42:58
Comments
Leave a Comment

Please login to continue.