File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1120,4 +1120,30 @@ describe(`getStore`, () => {
11201120 'The `getStore` method requires the name of the store as a string or as the `name` property of an options object' ,
11211121 )
11221122 } )
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+ } )
11231149} )
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export class Store {
3333
3434 constructor ( options : StoreOptions ) {
3535 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 )
3737 }
3838
3939 async delete ( key : string ) {
You can’t perform that action at this time.
0 commit comments