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
但是如何获取用户对服务器的请求URL ???
答案 0 :(得分:1)
只需像request.protocol
那样
exports.nameOfFunction = function(request, response){
var proto = request.protocol;
console.log(proto);
}