Skip to content

Commit

Permalink
Revert "fix: failing tests for domain parse util function"
Browse files Browse the repository at this point in the history
This reverts commit b7e0f8e.
  • Loading branch information
deepjyoti30-st committed Oct 1, 2024
1 parent b7e0f8e commit 1e93a05
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
13 changes: 3 additions & 10 deletions lib/build/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions lib/ts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,19 +345,11 @@ export function getTopLevelDomainForSameSiteResolution(url: string): string {
return "localhost";
}

// According to tests, if it is an ec2 subdomain, we want to return the subdomain
// as well. With `psl` library, this was not an issue because the library
// would return a `null` value for `domain` for ec2 urls.
//
// With tldts library, it parses the ec2 urls and returns the .amazonaws.com
// as the domain (instead of `null`) so we need to do the amazonaws check
// regardless of the domain being null.
if (hostname.endsWith(".amazonaws.com")) {
return hostname;
}

let parsedURL = parse(hostname);
if (!parsedURL.domain) {
if (hostname.endsWith(".amazonaws.com") && parsedURL.publicSuffix === hostname) {
return hostname;
}
// support for .local domain
if (hostname.endsWith(".local") && !parsedURL.publicSuffix) {
return hostname;
Expand Down
7 changes: 3 additions & 4 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ describe("getTopLevelDomainForSameSiteResolution test", () => {
assert.equal(getTopLevelDomainForSameSiteResolution("http://sub.domain.co.uk"), "domain.co.uk");
});

assert.strictEqual(
getTopLevelDomainForSameSiteResolution("https://ec2-xx-yyy-zzz-0.compute-1.amazonaws.com"),
"ec2-xx-yyy-zzz-0.compute-1.amazonaws.com"
);
it("should handle .amazonaws.com domains correctly", () => {
assert.equal(getTopLevelDomainForSameSiteResolution("https://my-instance.amazonaws.com"), "amazonaws.com");
});

it("should handle .local domains correctly", () => {
assert.equal(getTopLevelDomainForSameSiteResolution("http://myserver.local"), "myserver.local");
Expand Down

0 comments on commit 1e93a05

Please sign in to comment.