Skip to content

Commit

Permalink
fix(util-endpoints): parseArn when resourcePath contains both delimit…
Browse files Browse the repository at this point in the history
…ers (#6387)
  • Loading branch information
trivikr authored Aug 15, 2024
1 parent d7b1610 commit 63cb133
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/util-endpoints/src/lib/aws/parseArn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ describe(parseArn.name, () => {
resourceId: ["myTopic"],
},
],
[
"arn:aws:s3:us-west-2:123456789012:my:folder/my:file",
{
partition: "aws",
service: "s3",
region: "us-west-2",
accountId: "123456789012",
resourceId: ["my", "folder", "my", "file"],
},
],
];

it.each(VALID_TEST_CASES)("returns for valid arn %s", (input: string, outout: EndpointARN) => {
Expand Down
4 changes: 1 addition & 3 deletions packages/util-endpoints/src/lib/aws/parseArn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export const parseArn = (value: string): EndpointARN | null => {

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

const resourceId = resourcePath[0].includes(RESOURCE_DELIMITER)
? resourcePath[0].split(RESOURCE_DELIMITER)
: resourcePath;
const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat();

return {
partition,
Expand Down

0 comments on commit 63cb133

Please sign in to comment.