@@ -105,7 +105,7 @@ function stringEntriesFromFormData(formData) {
105105function mergeEntries ( searchParams , entries ) {
106106 for ( const [ name , value ] of entries ) {
107107 if ( value instanceof window . File ) continue ;
108- if ( searchParams . has ( name ) ) {
108+ if ( searchParams . has ( name ) && ! name . includes ( "[]" ) ) {
109109 searchParams . delete ( name ) ;
110110 searchParams . set ( name , value ) ;
111111 } else {
@@ -143,6 +143,16 @@ class FetchRequest {
143143 headers [ key ] = value ;
144144 this . options . headers = headers ;
145145 }
146+ sameHostname ( ) {
147+ if ( ! this . originalUrl . startsWith ( "http:" ) ) {
148+ return true ;
149+ }
150+ try {
151+ return new URL ( this . originalUrl ) . hostname === window . location . hostname ;
152+ } catch ( _ ) {
153+ return true ;
154+ }
155+ }
146156 get fetchOptions ( ) {
147157 return {
148158 method : this . method . toUpperCase ( ) ,
@@ -154,12 +164,15 @@ class FetchRequest {
154164 } ;
155165 }
156166 get headers ( ) {
157- return compact ( Object . assign ( {
167+ const baseHeaders = {
158168 "X-Requested-With" : "XMLHttpRequest" ,
159- "X-CSRF-Token" : this . csrfToken ,
160169 "Content-Type" : this . contentType ,
161170 Accept : this . accept
162- } , this . additionalHeaders ) ) ;
171+ } ;
172+ if ( this . sameHostname ( ) ) {
173+ baseHeaders [ "X-CSRF-Token" ] = this . csrfToken ;
174+ }
175+ return compact ( Object . assign ( baseHeaders , this . additionalHeaders ) ) ;
163176 }
164177 get csrfToken ( ) {
165178 return getCookie ( metaContent ( "csrf-param" ) ) || metaContent ( "csrf-token" ) ;
0 commit comments