Skip to content

Commit

Permalink
Fix permuteDomain with trailing dot (#216)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Waterman <65307+awaterma@users.noreply.github.com>
  • Loading branch information
ruoho-sfdc and awaterma committed Sep 27, 2021
1 parent 23bd608 commit e66a8b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/permuteDomain.js
Expand Up @@ -68,6 +68,11 @@ function permuteDomain(domain, allowSpecialUseDomain) {
return [domain];
}

// Nuke trailing dot
if (domain.slice(-1) == ".") {
domain = domain.slice(0, -1)
}

const prefix = domain.slice(0, -(pubSuf.length + 1)); // ".example.com"
const parts = prefix.split(".").reverse();
let cur = pubSuf;
Expand Down
10 changes: 10 additions & 0 deletions test/domain_and_path_test.js
Expand Up @@ -194,6 +194,16 @@ vows
"foo.bar.example.localduhmain"
]);
}
},
"trailing dot": {
topic: tough.permuteDomain.bind(null, "foo.bar.example.com."),
"got three things": function(list) {
assert.deepEqual(list, [
"example.com",
"bar.example.com",
"foo.bar.example.com"
]);
}
}
},
permutePath: {
Expand Down

0 comments on commit e66a8b1

Please sign in to comment.