Skip to content

Commit 3aad79f

Browse files
committed
feat(middleware-bucket-endpoint): refactor and add unit tests
1 parent bd552f9 commit 3aad79f

File tree

6 files changed

+523
-292
lines changed

6 files changed

+523
-292
lines changed

packages/middleware-bucket-endpoint/src/bucketArnUtils.spec.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/middleware-bucket-endpoint/src/bucketArnUtils.ts

Lines changed: 0 additions & 109 deletions
This file was deleted.

packages/middleware-bucket-endpoint/src/bucketEndpointMiddleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { parse as parseArn, validate as validateArn } from "@aws-sdk/util-arn-parser";
1212

1313
import { bucketHostname } from "./bucketHostname";
14+
import { getPseudoRegion } from "./bucketHostnameUtils";
1415
import { BucketEndpointResolvedConfig } from "./configurations";
1516

1617
export function bucketEndpointMiddleware(options: BucketEndpointResolvedConfig): BuildMiddleware<any, any> {
@@ -25,6 +26,8 @@ export function bucketEndpointMiddleware(options: BucketEndpointResolvedConfig):
2526
request.hostname = bucketName;
2627
} else {
2728
const clientRegion = await options.region();
29+
const { partition: clientPartition, signingRegion: clientSigningRegion } =
30+
(await options.regionInfoProvider(getPseudoRegion(clientRegion))) || {};
2831
const { hostname, bucketEndpoint } = bucketHostname({
2932
bucketName: validateArn(bucketName) ? parseArn(bucketName) : bucketName,
3033
baseHostname: request.hostname,
@@ -33,8 +36,8 @@ export function bucketEndpointMiddleware(options: BucketEndpointResolvedConfig):
3336
pathStyleEndpoint: options.forcePathStyle,
3437
tlsCompatible: request.protocol === "https:",
3538
useArnRegion: await options.useArnRegion(),
36-
clientRegion,
37-
clientPartition: (await options.regionInfoProvider(clientRegion))?.partition,
39+
clientPartition,
40+
clientSigningRegion,
3841
});
3942

4043
request.hostname = hostname;

0 commit comments

Comments
 (0)