Method description:
Insert or replace the original tag for URL or href. (If you don’t understand, you can look at examples)
Grammar:
url.resolve(from, to)
Since this method belongs to the url module, the url module needs to be introduced before use (var url= require(“url”) )
Receive parameters:
from Source address
to tags that need to be added or replaced
Example:
var url = require('url');
var a = url.resolve('/one/two/three', 'four') ,
b = url.resolve('http://example.com/', '/one'),
c = url.resolve('http://example.com/one', '/two');
console.log(a "," b "," c);
//Output result:
///one/two/four
//http://example.com/one
//http://example.com/two
Source code:
Url.prototype.resolve = function(relative) {
return this.resolveObject(urlParse(relative, false, true)).format();
};