File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -223,11 +223,16 @@ describe('header handling', () => {
223223
224224 describe ( 'csrf token inclusion' , ( ) => {
225225 // 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) ' , ( ) => {
227227 const request = new FetchRequest ( "get" , "http://removeservice.com/test.json" )
228228 expect ( request . fetchOptions . headers ) . not . toHaveProperty ( "X-CSRF-Token" )
229229 } )
230230
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+
231236 test ( 'csrf token is included in headers if url hostname is the same as window.location' , ( ) => {
232237 const request = new FetchRequest ( "get" , "http://localhost/test.json" )
233238 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 {
4949 }
5050
5151 sameHostname ( ) {
52- if ( ! this . originalUrl . startsWith ( 'http:' ) ) {
52+ if ( ! this . originalUrl . startsWith ( 'http:' ) && ! this . originalUrl . startsWith ( 'https:' ) ) {
5353 return true
5454 }
5555
You can’t perform that action at this time.
0 commit comments