From bd48a2a46d17f78828f0517b0232c4d5ef911cf5 Mon Sep 17 00:00:00 2001 From: rddimon Date: Thu, 7 Dec 2023 16:22:15 +0200 Subject: [PATCH] Hosted zone filtering fix --- CHANGELOG.md | 7 ++++++- package.json | 2 +- src/aws/route53-wrapper.ts | 2 +- test/unit-tests/aws/route53-wrapper.test.ts | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 239a1ac9..f9cccbf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [7.3.2] - 2023-12-07 + +### Fixed +- Fixed hosted zone filtering, when the domain `api.mydomain.com` equals the host name `api.mydomain.com`. + ## [7.3.1] - 2023-12-01 ### Fixed -- Fixed hosted zone filtering. +- Fixed hosted zone filtering, when the domain `serverlessdevapi.mydomain.com` contains the host name `api.mydomain.com`. ## [7.3.0] - 2023-11-30 diff --git a/package.json b/package.json index 557e01c4..52e3f582 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-domain-manager", - "version": "7.3.1", + "version": "7.3.2", "engines": { "node": ">=14" }, diff --git a/src/aws/route53-wrapper.ts b/src/aws/route53-wrapper.ts index f93f8173..269d8279 100644 --- a/src/aws/route53-wrapper.ts +++ b/src/aws/route53-wrapper.ts @@ -69,7 +69,7 @@ class Route53Wrapper { }) .filter((hostedZone) => { const hostedZoneName = hostedZone.Name.replace(/\.$/, ""); - return domainNameHost.endsWith(hostedZoneName); + return domain.givenDomainName === hostedZoneName || domainNameHost.endsWith(hostedZoneName); }) .sort((zone1, zone2) => zone2.Name.length - zone1.Name.length) .shift(); diff --git a/test/unit-tests/aws/route53-wrapper.test.ts b/test/unit-tests/aws/route53-wrapper.test.ts index 0f9f3c4c..6378754e 100644 --- a/test/unit-tests/aws/route53-wrapper.test.ts +++ b/test/unit-tests/aws/route53-wrapper.test.ts @@ -169,13 +169,13 @@ describe("Route53 wrapper checks", () => { Name: "api.test_domain", }, { CallerReference: "", - Config: {PrivateZone: true}, - Id: "dummy_host_id", - Name: "test_domain", + Config: {PrivateZone: false}, + Id: testId, + Name: "devapi.test_domain", }, { CallerReference: "", Config: {PrivateZone: false}, - Id: testId, + Id: "dummy_host_id", Name: "test_domain", }, ]