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();
};
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn