Skip to content

Commit

Permalink
fix(util-endpoints): handle case when resourcePath contains both deli…
Browse files Browse the repository at this point in the history
…miters
  • Loading branch information
trivikr committed Aug 13, 2024
1 parent 7d9d9ad commit 855f1fa
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 855f1fa

Please sign in to comment.