Skip to content

Commit ce4db0d

Browse files
committed
chore: move replacing of dualstack to bucketHostname
1 parent 7a57d5b commit ce4db0d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ export interface BucketHostname {
3333

3434
export const bucketHostname = (options: BucketHostnameParams | ArnHostnameParams): BucketHostname => {
3535
validateCustomEndpoint(options);
36+
37+
// TODO: Remove checks for ".dualstack" from entire middleware.
38+
const { dualstackEndpoint, baseHostname } = options;
39+
const updatedBaseHostname = dualstackEndpoint ? baseHostname.replace(".dualstack", "") : baseHostname;
40+
3641
return isBucketNameOptions(options)
3742
? // Construct endpoint when bucketName is a string referring to a bucket name
38-
getEndpointFromBucketName(options)
43+
getEndpointFromBucketName({ ...options, baseHostname: updatedBaseHostname })
3944
: // Construct endpoint when bucketName is an ARN referring to an S3 resource like Access Point
40-
getEndpointFromArn(options);
45+
getEndpointFromArn({ ...options, baseHostname: updatedBaseHostname });
4146
};
4247

4348
const getEndpointFromBucketName = ({
@@ -51,9 +56,7 @@ const getEndpointFromBucketName = ({
5156
tlsCompatible = true,
5257
isCustomEndpoint = false,
5358
}: BucketHostnameParams): BucketHostname => {
54-
// TODO: Remove checks for ".dualstack" from entire middleware.
55-
const suffixHostname = dualstackEndpoint ? baseHostname.replace(".dualstack", "") : baseHostname;
56-
const [clientRegion, hostnameSuffix] = isCustomEndpoint ? [region, baseHostname] : getSuffix(suffixHostname);
59+
const [clientRegion, hostnameSuffix] = isCustomEndpoint ? [region, baseHostname] : getSuffix(baseHostname);
5760
if (pathStyleEndpoint || !isDnsCompatibleBucketName(bucketName) || (tlsCompatible && DOT_PATTERN.test(bucketName))) {
5861
return {
5962
bucketEndpoint: false,

0 commit comments

Comments
 (0)