File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,13 @@ var events = require('events'),
30
30
url = require ( 'url' ) ,
31
31
httpProxy = require ( '../node-http-proxy' ) ;
32
32
33
+ //
34
+ // @private {RegExp} extractPort
35
+ // Reusable regular expression for getting the
36
+ // port from a host string.
37
+ //
38
+ var extractPort = / : ( \d + ) $ / ;
39
+
33
40
//
34
41
// ### function HttpProxy (options)
35
42
// #### @options {Object} Options for this instance.
@@ -957,14 +964,12 @@ HttpProxy.prototype._forwardRequest = function (req) {
957
964
} ;
958
965
959
966
function getPortFromHostHeader ( req ) {
960
- var portMatch = req . headers . host . match ( / : ( \d + ) $ / ) ;
961
-
962
- if ( portMatch ) {
963
- return parseInt ( portMatch [ 1 ] ) ;
964
- }
965
- else {
966
- return getProto ( req ) === 'https' ? 443 : 80 ;
967
+ var match ;
968
+ if ( ( match = extractPort . exec ( req . headers . host ) ) ) {
969
+ return parseInt ( match [ 1 ] ) ;
967
970
}
971
+
972
+ return getProto ( req ) === 'https' ? 443 : 80 ;
968
973
}
969
974
970
975
function getProto ( req ) {
You can’t perform that action at this time.
0 commit comments