Skip to content

Commit 63cb133

Browse files
authored
fix(util-endpoints): parseArn when resourcePath contains both delimiters (#6387)
1 parent d7b1610 commit 63cb133

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/util-endpoints/src/lib/aws/parseArn.spec.ts

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ describe(parseArn.name, () => {
7474
resourceId: ["myTopic"],
7575
},
7676
],
77+
[
78+
"arn:aws:s3:us-west-2:123456789012:my:folder/my:file",
79+
{
80+
partition: "aws",
81+
service: "s3",
82+
region: "us-west-2",
83+
accountId: "123456789012",
84+
resourceId: ["my", "folder", "my", "file"],
85+
},
86+
],
7787
];
7888

7989
it.each(VALID_TEST_CASES)("returns for valid arn %s", (input: string, outout: EndpointARN) => {

packages/util-endpoints/src/lib/aws/parseArn.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export const parseArn = (value: string): EndpointARN | null => {
1717

1818
if (arn !== "arn" || partition === "" || service === "" || resourcePath.join(ARN_DELIMITER) === "") return null;
1919

20-
const resourceId = resourcePath[0].includes(RESOURCE_DELIMITER)
21-
? resourcePath[0].split(RESOURCE_DELIMITER)
22-
: resourcePath;
20+
const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat();
2321

2422
return {
2523
partition,

0 commit comments

Comments
 (0)