File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
src/core/signal-generators Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,23 @@ describe(matchHostname, () => {
48
48
setLocation ( { hostname : 'api.example.com' } )
49
49
expect ( matchHostname ( 'https://api.example.com/foo' ) ) . toBe ( true )
50
50
expect ( matchHostname ( 'https://foo.com/foo' ) ) . toBe ( false )
51
- expect ( matchHostname ( 'https://example.com/foo' ) ) . toBe ( false )
51
+ expect ( matchHostname ( 'https://example.com/foo' ) ) . toBe ( true )
52
52
} )
53
53
54
54
it ( 'should always allow relative domains' , ( ) => {
55
55
expect ( matchHostname ( '/foo/bar' ) ) . toBe ( true )
56
56
expect ( matchHostname ( 'foo/bar' ) ) . toBe ( true )
57
57
expect ( matchHostname ( 'foo' ) ) . toBe ( true )
58
58
} )
59
+
60
+ it ( 'should handle www differences' , ( ) => {
61
+ setLocation ( { hostname : 'foo.previews.console.stage.twilio.com' } )
62
+ expect (
63
+ matchHostname (
64
+ 'https://www.stage.twilio.com/console/billing/api/v3/add-funds'
65
+ )
66
+ ) . toBe ( true )
67
+ } )
59
68
} )
60
69
61
70
describe ( addFetchInterceptor , ( ) => {
Original file line number Diff line number Diff line change @@ -33,7 +33,10 @@ export const matchHostname = (url: string): boolean => {
33
33
// Relative URL will go to this host
34
34
return true
35
35
}
36
- return new URL ( url ) . hostname . includes ( window . location . hostname )
36
+
37
+ const clean = new URL ( url ) . hostname . replace ( 'www.' , '' )
38
+ const current = window . location . hostname . replace ( 'www.' , '' )
39
+ return clean . includes ( current ) || current . includes ( clean )
37
40
}
38
41
39
42
const normalizeHeaders = ( headers : HeadersInit ) : Headers => {
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ module.exports = merge(common, {
14
14
type : 'umd' ,
15
15
} ,
16
16
} ,
17
+ 'analytics-signals.global' : {
18
+ import : path . resolve ( __dirname , 'src/index.ts' ) ,
19
+ library : {
20
+ type : 'window' ,
21
+ } ,
22
+ } ,
17
23
} ,
18
24
output : {
19
25
filename : isProd ? '[name].js' : '[name].development.js' ,
You can’t perform that action at this time.
0 commit comments