const URL = require('url').URL;
const myURL = new URL('https://example.org/foo');
console.log(myURL.href); // https://example.org/foo
console.log(myURL.protocol); // https:
console.log(myURL.hostname); // example.org
console.log(myURL.pathname); // /foo
但是,如何获取用户向服务器发出的请求网址呢???
只需通过request.protocol
喜欢
exports.nameOfFunction = function(request, response){
var proto = request.protocol;
console.log(proto);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句