diff --git a/lib/request.js b/lib/request.js index e075cbe0f..fd4c976ad 100644 --- a/lib/request.js +++ b/lib/request.js @@ -257,7 +257,7 @@ module.exports = { if (!host) host = this.get('Host'); } 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; if (!host) return ''; 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.app.proxy) return 'http'; const proto = this.get('X-Forwarded-Proto'); - return proto ? proto.split(/\s*,\s*/)[0] : 'http'; + return proto ? proto.split(/\s*,\s*/, 1)[0] : 'http'; }, /** diff --git a/lib/response.js b/lib/response.js index b7d77dea8..c01526e1c 100644 --- a/lib/response.js +++ b/lib/response.js @@ -381,7 +381,7 @@ module.exports = { get type() { const type = this.get('Content-Type'); if (!type) return ''; - return type.split(';')[0]; + return type.split(';', 1)[0]; }, /**