File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -223,11 +223,16 @@ describe('header handling', () => {
223
223
224
224
describe ( 'csrf token inclusion' , ( ) => {
225
225
// window.location.hostname is "localhost" in the test suite
226
- test ( 'csrf token is not included in headers if url hostname is not the same as window.location' , ( ) => {
226
+ test ( 'csrf token is not included in headers if url hostname is not the same as window.location (http) ' , ( ) => {
227
227
const request = new FetchRequest ( "get" , "http://removeservice.com/test.json" )
228
228
expect ( request . fetchOptions . headers ) . not . toHaveProperty ( "X-CSRF-Token" )
229
229
} )
230
230
231
+ test ( 'csrf token is not included in headers if url hostname is not the same as window.location (https)' , ( ) => {
232
+ const request = new FetchRequest ( "get" , "https://removeservice.com/test.json" )
233
+ expect ( request . fetchOptions . headers ) . not . toHaveProperty ( "X-CSRF-Token" )
234
+ } )
235
+
231
236
test ( 'csrf token is included in headers if url hostname is the same as window.location' , ( ) => {
232
237
const request = new FetchRequest ( "get" , "http://localhost/test.json" )
233
238
expect ( request . fetchOptions . headers ) . toHaveProperty ( "X-CSRF-Token" )
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export class FetchRequest {
49
49
}
50
50
51
51
sameHostname ( ) {
52
- if ( ! this . originalUrl . startsWith ( 'http:' ) ) {
52
+ if ( ! this . originalUrl . startsWith ( 'http:' ) && ! this . originalUrl . startsWith ( 'https:' ) ) {
53
53
return true
54
54
}
55
55
You can’t perform that action at this time.
0 commit comments