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
Run Code Online (Sandbox Code Playgroud)
但是我如何获取用户向服务器发出的请求 url ???
小智 8
request.protocol只需这样做
exports.nameOfFunction = function(request, response){
var proto = request.protocol;
console.log(proto);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9486 次 |
| 最近记录: |