Simplify processes in the getter request.protocol (#1203)

This commit is contained in:
initial-wu 2018-06-07 22:50:26 +08:00 committed by fengmk2
parent 4d42500e76
commit 77a4cfb829

View file

@ -397,11 +397,10 @@ module.exports = {
*/
get protocol() {
const proxy = this.app.proxy;
if (this.socket.encrypted) return 'https';
if (!proxy) return 'http';
const proto = this.get('X-Forwarded-Proto') || 'http';
return proto.split(/\s*,\s*/)[0];
if (!this.app.proxy) return 'http';
const proto = this.get('X-Forwarded-Proto');
return proto ? proto.split(/\s*,\s*/)[0] : 'http';
},
/**