File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @web-std/fetch " : feat
3
+ ---
4
+
5
+ Add support for custom ` credentials ` value. Nothing is done with them at the moment but they pass through for the consumer of the request to access if needed.
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ const isRequest = object => {
37
37
* @property {string } method
38
38
* @property {RequestRedirect } redirect
39
39
* @property {globalThis.Headers } headers
40
+ * @property {RequestCredentials } credentials
40
41
* @property {URL } parsedURL
41
42
* @property {AbortSignal|null } signal
42
43
*
@@ -125,6 +126,7 @@ export default class Request extends Body {
125
126
method,
126
127
redirect : init . redirect || input . redirect || 'follow' ,
127
128
headers,
129
+ credentials : init . credentials || 'same-origin' ,
128
130
parsedURL,
129
131
signal : signal || null
130
132
} ;
@@ -159,7 +161,7 @@ export default class Request extends Body {
159
161
*/
160
162
161
163
get credentials ( ) {
162
- return "same-origin"
164
+ return this [ INTERNALS ] . credentials
163
165
}
164
166
165
167
/**
Original file line number Diff line number Diff line change @@ -111,6 +111,16 @@ describe('Request', () => {
111
111
expect ( derivedRequest . signal ) . to . equal ( null ) ;
112
112
} ) ;
113
113
114
+ it ( 'should default to "same-origin" as credentials' , ( ) => {
115
+ const request = new Request ( base )
116
+ expect ( request . credentials ) . to . equal ( 'same-origin' ) ;
117
+ } )
118
+
119
+ it ( 'should respect custom credentials value' , ( ) => {
120
+ expect ( new Request ( base , { credentials : 'omit' } ) ) . to . have . property ( 'credentials' , 'omit' ) ;
121
+ expect ( new Request ( base , { credentials : 'include' } ) ) . to . have . property ( 'credentials' , 'include' ) ;
122
+ } )
123
+
114
124
it ( 'should throw error with GET/HEAD requests with body' , ( ) => {
115
125
expect ( ( ) => new Request ( base , { body : '' } ) )
116
126
. to . throw ( TypeError ) ;
You can’t perform that action at this time.
0 commit comments