File tree Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Expand file tree Collapse file tree 3 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { URLPattern } from "urlpattern-polyfill";
19
19
import { TlsHandshakeFailure } from '../types' ;
20
20
import { getCA } from '../util/tls' ;
21
21
import { delay } from '../util/util' ;
22
+ import { shouldPassThrough } from '../util/server-utils' ;
22
23
import {
23
24
getParentSocket ,
24
25
buildSocketTimingInfo ,
@@ -421,22 +422,3 @@ function analyzeAndMaybePassThroughTls(
421
422
tlsConnectionListener . call ( server , socket ) ;
422
423
} ) ;
423
424
}
424
-
425
- export function shouldPassThrough (
426
- hostname : string | undefined ,
427
- // Only one of these two should have values (validated above):
428
- passThroughPatterns : URLPattern [ ] ,
429
- interceptOnlyPatterns : URLPattern [ ] | undefined
430
- ) : boolean {
431
- if ( ! hostname ) return false ;
432
-
433
- if ( interceptOnlyPatterns ) {
434
- return ! interceptOnlyPatterns . some ( ( pattern ) =>
435
- pattern . test ( `https://${ hostname } ` )
436
- ) ;
437
- }
438
-
439
- return passThroughPatterns . some ( ( pattern ) =>
440
- pattern . test ( `https://${ hostname } ` )
441
- ) ;
442
- }
Original file line number Diff line number Diff line change
1
+ export function shouldPassThrough (
2
+ hostname : string | undefined ,
3
+ // Only one of these two should have values (validated above):
4
+ passThroughPatterns : URLPattern [ ] ,
5
+ interceptOnlyPatterns : URLPattern [ ] | undefined
6
+ ) : boolean {
7
+ if ( ! hostname ) return false ;
8
+
9
+ if ( interceptOnlyPatterns ) {
10
+ return ! interceptOnlyPatterns . some ( ( pattern ) =>
11
+ pattern . test ( `https://${ hostname } ` )
12
+ ) ;
13
+ }
14
+
15
+ return passThroughPatterns . some ( ( pattern ) =>
16
+ pattern . test ( `https://${ hostname } ` )
17
+ ) ;
18
+ }
Original file line number Diff line number Diff line change 1
1
import { URLPattern } from "urlpattern-polyfill" ;
2
- import { shouldPassThrough } from "../src/server/http-combo-server" ;
3
2
import { expect } from "./test-utils" ;
3
+ import { shouldPassThrough } from "../src/util/server-utils" ;
4
4
5
5
describe ( "shouldPassThrough" , ( ) => {
6
6
it ( "should return false when passThroughHostnames is empty and interceptOnlyHostnames is undefined" , async ( ) => {
You can’t perform that action at this time.
0 commit comments