url.resolve(from, to)
稳定性: 0 - 弃用: 改为使用 WHATWG URL API 。
url.resolve()
方法以类似于 Web 浏览器解析锚标记 HREF 的方式解析相对于基本网址的目标网址。
const url = require('url');
url.resolve('/one/two/three', 'four'); // '/one/two/four'
url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
Stability: 0 - Deprecated: Use the WHATWG URL API instead.
The url.resolve()
method resolves a target URL relative to a base URL in a
manner similar to that of a Web browser resolving an anchor tag HREF.
const url = require('url');
url.resolve('/one/two/three', 'four'); // '/one/two/four'
url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'