File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1120,4 +1120,30 @@ describe(`getStore`, () => {
1120
1120
'The `getStore` method requires the name of the store as a string or as the `name` property of an options object' ,
1121
1121
)
1122
1122
} )
1123
+
1124
+ test ( 'URL-encodes the store name' , async ( ) => {
1125
+ const mockStore = new MockFetch ( )
1126
+ . get ( {
1127
+ headers : { authorization : `Bearer ${ apiToken } ` } ,
1128
+ response : new Response ( JSON . stringify ( { url : signedURL } ) ) ,
1129
+ url : `https://api.netlify.com/api/v1/sites/${ siteID } /blobs/${ key } ?context=%2Fwhat%3F` ,
1130
+ } )
1131
+ . get ( {
1132
+ response : new Response ( value ) ,
1133
+ url : signedURL ,
1134
+ } )
1135
+
1136
+ globalThis . fetch = mockStore . fetch
1137
+
1138
+ const blobs = getStore ( {
1139
+ name : '/what?' ,
1140
+ token : apiToken ,
1141
+ siteID,
1142
+ } )
1143
+
1144
+ const string = await blobs . get ( key )
1145
+ expect ( string ) . toBe ( value )
1146
+
1147
+ expect ( mockStore . fulfilled ) . toBeTruthy ( )
1148
+ } )
1123
1149
} )
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export class Store {
33
33
34
34
constructor ( options : StoreOptions ) {
35
35
this . client = options . client
36
- this . name = 'deployID' in options ? `deploy:${ options . deployID } ` : options . name
36
+ this . name = 'deployID' in options ? `deploy:${ options . deployID } ` : encodeURIComponent ( options . name )
37
37
}
38
38
39
39
async delete ( key : string ) {
You can’t perform that action at this time.
0 commit comments