diff --git a/__tests__/aws.test.ts b/__tests__/aws.test.ts index 55a368c..807848c 100644 --- a/__tests__/aws.test.ts +++ b/__tests__/aws.test.ts @@ -10,6 +10,7 @@ describe('isECR', () => { ['012345678901.dkr.ecr.eu-west-3.amazonaws.com', true], ['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', true], ['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', true], + ['012345678901.dkr-ecr.eu-north-1.on.aws', true], ['public.ecr.aws', true] ])('given registry %p', async (registry, expected) => { expect(aws.isECR(registry)).toEqual(expected); @@ -23,6 +24,7 @@ describe('isPubECR', () => { ['012345678901.dkr.ecr.eu-west-3.amazonaws.com', false], ['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', false], ['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', false], + ['012345678901.dkr-ecr.eu-north-1.on.aws', false], ['public.ecr.aws', true] ])('given registry %p', async (registry, expected) => { expect(aws.isPubECR(registry)).toEqual(expected); @@ -34,6 +36,7 @@ describe('getRegion', () => { ['012345678901.dkr.ecr.eu-west-3.amazonaws.com', 'eu-west-3'], ['876820548815.dkr.ecr.cn-north-1.amazonaws.com.cn', 'cn-north-1'], ['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', 'cn-northwest-1'], + ['012345678901.dkr-ecr.eu-north-1.on.aws', 'eu-north-1'], ['public.ecr.aws', 'us-east-1'] ])('given registry %p', async (registry, expected) => { expect(aws.getRegion(registry)).toEqual(expected); @@ -46,6 +49,7 @@ describe('getAccountIDs', () => { ['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678910,023456789012', ['012345678901', '012345678910', '023456789012']], ['012345678901.dkr.ecr.eu-west-3.amazonaws.com', '012345678901,012345678910,023456789012', ['012345678901', '012345678910', '023456789012']], ['390948362332.dkr.ecr.cn-northwest-1.amazonaws.com.cn', '012345678910,023456789012', ['390948362332', '012345678910', '023456789012']], + ['876820548815.dkr-ecr.eu-north-1.on.aws', '012345678910,023456789012', ['876820548815', '012345678910', '023456789012']], ['public.ecr.aws', undefined, []] ])('given registry %p', async (registry, accountIDsEnv, expected) => { if (accountIDsEnv) { diff --git a/src/aws.ts b/src/aws.ts index 6bb4001..feb0452 100644 --- a/src/aws.ts +++ b/src/aws.ts @@ -5,7 +5,7 @@ import {NodeHttpHandler} from '@smithy/node-http-handler'; import {HttpProxyAgent} from 'http-proxy-agent'; import {HttpsProxyAgent} from 'https-proxy-agent'; -const ecrRegistryRegex = /^(([0-9]{12})\.dkr\.ecr\.(.+)\.amazonaws\.com(.cn)?)(\/([^:]+)(:.+)?)?$/; +const ecrRegistryRegex = /^(([0-9]{12})\.(dkr\.ecr|dkr-ecr)\.(.+)\.(on\.aws|amazonaws\.com(.cn)?))(\/([^:]+)(:.+)?)?$/; export const isECR = (registry: string): boolean => { return ecrRegistryRegex.test(registry) || isPubECR(registry); @@ -23,7 +23,7 @@ export const getRegion = (registry: string): string => { if (!matches) { return ''; } - return matches[3]; + return matches[4]; }; export const getAccountIDs = (registry: string): string[] => {