File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,15 @@ export default class Connection {
4343 params . host = params . host . slice ( 0 , - 1 ) ;
4444 }
4545
46- const protocolPattern = / ^ ( h t t p s ? : \/ \/ | f t p : \/ \/ | f i l e : \/ \/ ) / ;
46+ const protocolPattern = / ^ ( h t t p s ? | f t p | f i l e ) (?: : \/ \/ ) / ;
4747 const extractedSchemeMatch = params . host . match ( protocolPattern ) ;
4848
4949 // Check for the existence of scheme in params
5050 if ( params . scheme ) {
5151 // If the host contains a scheme different than provided scheme, replace it and throw a warning
52- if ( extractedSchemeMatch && extractedSchemeMatch [ 0 ] !== `${ params . scheme } :// ` ) {
52+ if ( extractedSchemeMatch && extractedSchemeMatch [ 1 ] !== `${ params . scheme } ` ) {
5353 throw new Error (
54- `The host contains a different protocol than specified in the scheme (scheme: ${ params . scheme } :// != host: ${ extractedSchemeMatch [ 0 ] } )`
54+ `The host contains a different protocol than specified in the scheme (scheme: ${ params . scheme } != host: ${ extractedSchemeMatch [ 1 ] } )`
5555 ) ;
5656 } else if ( ! extractedSchemeMatch ) {
5757 // If no scheme in the host, simply prefix with the provided scheme
@@ -60,7 +60,7 @@ export default class Connection {
6060 // If there's no scheme in params, ensure the host starts with a recognized protocol
6161 } else if ( ! extractedSchemeMatch ) {
6262 throw new Error (
63- 'The host must start with a recognized protocol (e.g., http:// or https:// ) if no scheme is provided.'
63+ 'The host must start with a recognized protocol (e.g., http or https) if no scheme is provided.'
6464 ) ;
6565 }
6666
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ describe('mock server auth tests', () => {
174174 } ;
175175
176176 expect ( createConnection ) . toThrow (
177- 'The host contains a different protocol than specified in the scheme (scheme: https:// != host: http:// )'
177+ 'The host contains a different protocol than specified in the scheme (scheme: https != host: http)'
178178 ) ;
179179 } ) ;
180180
@@ -189,7 +189,7 @@ describe('mock server auth tests', () => {
189189 } ;
190190
191191 expect ( createConnection ) . toThrow (
192- 'The host must start with a recognized protocol (e.g., http:// or https:// ) if no scheme is provided.'
192+ 'The host must start with a recognized protocol (e.g., http or https) if no scheme is provided.'
193193 ) ;
194194 } ) ;
195195
You can’t perform that action at this time.
0 commit comments