File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { Buffer } from 'node:buffer'
1
2
import { promises as fs } from 'node:fs'
2
3
import { env , version as nodeVersion } from 'node:process'
3
4
@@ -429,3 +430,34 @@ test('Returns a signed URL or the blob directly based on the request parameters'
429
430
await server . stop ( )
430
431
await fs . rm ( directory . path , { force : true , recursive : true } )
431
432
} )
433
+
434
+ test ( 'Accepts stores with `experimentalRegion`' , async ( ) => {
435
+ const deployID = '655f77a1b48f470008e5879a'
436
+ const directory = await tmp . dir ( )
437
+ const server = new BlobsServer ( {
438
+ directory : directory . path ,
439
+ token,
440
+ } )
441
+ const { port } = await server . start ( )
442
+
443
+ const context = {
444
+ deployID,
445
+ edgeURL : `http://localhost:${ port } ` ,
446
+ primaryRegion : 'us-east-1' ,
447
+ siteID,
448
+ token,
449
+ }
450
+
451
+ env . NETLIFY_BLOBS_CONTEXT = Buffer . from ( JSON . stringify ( context ) ) . toString ( 'base64' )
452
+
453
+ const store = getDeployStore ( { experimentalRegion : 'context' } )
454
+ const key = 'my-key'
455
+ const value = 'hello from a deploy store'
456
+
457
+ await store . set ( key , value )
458
+
459
+ expect ( await store . get ( key ) ) . toBe ( value )
460
+
461
+ await server . stop ( )
462
+ await fs . rm ( directory . path , { force : true , recursive : true } )
463
+ } )
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { isNodeError, Logger } from './util.ts'
16
16
const API_URL_PATH = / \/ a p i \/ v 1 \/ b l o b s \/ (?< site_id > [ ^ / ] + ) \/ (?< store_name > [ ^ / ] + ) \/ ? (?< key > [ ^ ? ] * ) /
17
17
const LEGACY_API_URL_PATH = / \/ a p i \/ v 1 \/ s i t e s \/ (?< site_id > [ ^ / ] + ) \/ b l o b s \/ ? (?< key > [ ^ ? ] * ) /
18
18
const LEGACY_DEFAULT_STORE = 'production'
19
+ const REGION_PREFIX = 'region:'
19
20
20
21
export enum Operation {
21
22
DELETE = 'delete' ,
@@ -335,7 +336,13 @@ export class BlobsServer {
335
336
return { }
336
337
}
337
338
338
- const [ , siteID , rawStoreName , ...key ] = url . pathname . split ( '/' )
339
+ let parts = url . pathname . split ( '/' ) . slice ( 1 )
340
+
341
+ if ( parts [ 0 ] . startsWith ( REGION_PREFIX ) ) {
342
+ parts = parts . slice ( 1 )
343
+ }
344
+
345
+ const [ siteID , rawStoreName , ...key ] = parts
339
346
340
347
if ( ! siteID ) {
341
348
return { }
You can’t perform that action at this time.
0 commit comments