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); //输出结果: ///one/two/four //http://example.com/one //http://example.com/two