Skip to content

Commit 09c55d7

Browse files
committed
fix: normalize domains to ensure FQDN equality
1 parent 2c37c13 commit 09c55d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const ALLOWED_TXT_OPTIONS: Readonly<string[]> = ['authSource', 'replicaSet', 'lo
1515

1616
function matchesParentDomain (srvAddress: string, parentDomain: string): boolean {
1717
const regex = /^.*?\./;
18-
const srv = `.${srvAddress.replace(regex, '')}`;
19-
const parent = `.${parentDomain.replace(regex, '')}`;
18+
const srv = `.${(srvAddress.endsWith(".") ? srvAddress.slice(0, -1) : srvAddress).replace(regex, "")}`;
19+
const parent = `.${(parentDomain.endsWith(".") ? parentDomain.slice(0, -1) : parentDomain).replace(regex, "")}`;
2020
return srv.endsWith(parent);
2121
}
2222

0 commit comments

Comments
 (0)