chore: Optimize array split (#1295)
This commit is contained in:
parent
9be8583125
commit
d9ef60398e
2 changed files with 4 additions and 4 deletions
|
@ -257,7 +257,7 @@ module.exports = {
|
||||||
if (!host) host = this.get('Host');
|
if (!host) host = this.get('Host');
|
||||||
}
|
}
|
||||||
if (!host) return '';
|
if (!host) return '';
|
||||||
return host.split(/\s*,\s*/)[0];
|
return host.split(/\s*,\s*/, 1)[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,7 +273,7 @@ module.exports = {
|
||||||
const host = this.host;
|
const host = this.host;
|
||||||
if (!host) return '';
|
if (!host) return '';
|
||||||
if ('[' == host[0]) return this.URL.hostname || ''; // IPv6
|
if ('[' == host[0]) return this.URL.hostname || ''; // IPv6
|
||||||
return host.split(':')[0];
|
return host.split(':', 1)[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,7 +404,7 @@ module.exports = {
|
||||||
if (this.socket.encrypted) return 'https';
|
if (this.socket.encrypted) return 'https';
|
||||||
if (!this.app.proxy) return 'http';
|
if (!this.app.proxy) return 'http';
|
||||||
const proto = this.get('X-Forwarded-Proto');
|
const proto = this.get('X-Forwarded-Proto');
|
||||||
return proto ? proto.split(/\s*,\s*/)[0] : 'http';
|
return proto ? proto.split(/\s*,\s*/, 1)[0] : 'http';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -381,7 +381,7 @@ module.exports = {
|
||||||
get type() {
|
get type() {
|
||||||
const type = this.get('Content-Type');
|
const type = this.get('Content-Type');
|
||||||
if (!type) return '';
|
if (!type) return '';
|
||||||
return type.split(';')[0];
|
return type.split(';', 1)[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue