The URL module provides 3 methods:parse,format,resolve
1. Parse
To introduce the URL module first
>url. Parse (' Http://www.cnblogs.com/cate/108703?from=scott&course=node#floor ')
Returns a JSON object that contains the various data for the URL
If the second parameter is set to true, query becomes an object. This parameter sets whether to use the QueryString module to process the query string.
QueryString methods for extracting objects from strings are: Parse, encode, etc.
Parse: Turn the string into an object, note that the URL module is different from the parse, part of the Knowledge URL module.
Encode: Converting a JSON object into a query string
2. Format
If there is a JSON object in hand, how to change back to the URL?
Use the url.format () function.
Sometimes, version agreements are not known . How does parsing not go wrong?
If the address is://imooc.com/course/list
Set the first three parameters to True, (false by default)
, three-time parameter change:
3, resolve (not sure)
Url.resolve (From,to)
Original address, Next level address
Online check, these are output the same results, that is, the first result. But I'm running it, really.
If anyone knows why, please tell.
The article is my study note, if there is a mistake, look
Nodejs Processing URL Tool