@@ -4,25 +4,46 @@ import type { Client } from '../../../src/client';
4
4
5
5
describe ( 'isSentryRequestUrl' , ( ) => {
6
6
it . each ( [
7
- [ 'http://sentry-dsn.com/my-url?sentry_key=123' , 'sentry-dsn.com' , '' , true ] ,
8
- [ 'http://tunnel:4200' , 'sentry-dsn.com' , 'http://tunnel:4200' , true ] ,
9
- [ 'http://tunnel:4200' , 'sentry-dsn.com' , 'http://tunnel:4200/' , true ] ,
10
- [ 'http://tunnel:4200/' , 'sentry-dsn.com' , 'http://tunnel:4200' , true ] ,
11
- [ 'http://tunnel:4200/' , 'another-dsn.com' , 'http://tunnel:4200' , true ] ,
7
+ [ 'http://sentry-dsn.com/my-url?sentry_key=123' , 'sentry-dsn.com' , '' ] ,
12
8
13
- [ 'http://tunnel:4200/?sentry_key=123' , 'another-dsn.com' , '' , false ] ,
14
- [ 'http://sentry-dsn.com/my-url' , 'sentry-dsn.com' , '' , false ] ,
15
- [ 'http://sentry-dsn.com' , 'sentry-dsn.com' , '' , false ] ,
16
- [ 'http://tunnel:4200/' , 'another-dsn.com' , 'http://tunnel:4200/sentry-tunnel' , false ] ,
17
- [ '' , 'sentry-dsn.com' , '' , false ] ,
18
- [ 'http://tunnel:4200/a' , 'sentry-dsn.com' , 'http://tunnel:4200' , false ] ,
19
- ] ) ( 'works with url=%s, dsn=%s, tunnel=%s' , ( url : string , dsn : string , tunnel : string , expected : boolean ) => {
9
+ [ 'http://tunnel:4200' , 'sentry-dsn.com' , 'http://tunnel:4200' ] ,
10
+ [ 'http://tunnel:4200' , 'sentry-dsn.com' , 'http://tunnel:4200/' ] ,
11
+ [ 'http://tunnel:4200/' , 'sentry-dsn.com' , 'http://tunnel:4200' ] ,
12
+ [ 'http://tunnel:4200/' , 'another-dsn.com' , 'http://tunnel:4200' ] ,
13
+ ] ) ( 'returns `true` for url=%s, dsn=%s, tunnel=%s' , ( url : string , dsn : string , tunnel : string ) => {
20
14
const client = {
21
15
getOptions : ( ) => ( { tunnel } ) ,
22
16
getDsn : ( ) => ( { host : dsn } ) ,
23
17
} as unknown as Client ;
24
18
25
- // Works with client passed
26
- expect ( isSentryRequestUrl ( url , client ) ) . toBe ( expected ) ;
19
+ expect ( isSentryRequestUrl ( url , client ) ) . toBe ( true ) ;
20
+ } ) ;
21
+
22
+ it . each ( [
23
+ [ 'http://tunnel:4200/?sentry_key=123' , 'another-dsn.com' , '' ] ,
24
+ [ 'http://sentry-dsn.com/my-url' , 'sentry-dsn.com' , '' ] ,
25
+ [ 'http://sentry-dsn.com' , 'sentry-dsn.com' , '' ] ,
26
+ [ 'http://sAntry-dsn.com/?sentry_key=123' , 'sentry-dsn.com' , '' ] ,
27
+ [ 'http://sAntry-dsn.com/?sAntry_key=123' , 'sAntry-dsn.com' , '' ] ,
28
+ [ '/ingest' , 'sentry-dsn.com' , '' ] ,
29
+ [ '/ingest?sentry_key=123' , 'sentry-dsn.com' , '' ] ,
30
+ [ '/ingest' , '' , '' ] ,
31
+ [ '' , '' , '' ] ,
32
+ [ '' , 'sentry-dsn.com' , '' ] ,
33
+
34
+ [ 'http://tunnel:4200/' , 'another-dsn.com' , 'http://tunnel:4200/sentry-tunnel' ] ,
35
+ [ 'http://tunnel:4200/a' , 'sentry-dsn.com' , 'http://tunnel:4200' ] ,
36
+ [ 'http://tunnel:4200/a' , '' , 'http://tunnel:4200/' ] ,
37
+ ] ) ( 'returns `false` for url=%s, dsn=%s, tunnel=%s' , ( url : string , dsn : string , tunnel : string ) => {
38
+ const client = {
39
+ getOptions : ( ) => ( { tunnel } ) ,
40
+ getDsn : ( ) => ( { host : dsn } ) ,
41
+ } as unknown as Client ;
42
+
43
+ expect ( isSentryRequestUrl ( url , client ) ) . toBe ( false ) ;
44
+ } ) ;
45
+
46
+ it ( 'handles undefined client' , ( ) => {
47
+ expect ( isSentryRequestUrl ( 'http://sentry-dsn.com/my-url?sentry_key=123' , undefined ) ) . toBe ( false ) ;
27
48
} ) ;
28
49
} ) ;
0 commit comments