Skip to content

Commit

Permalink
fix: failing tests for domain parse util function (#931)
Browse files Browse the repository at this point in the history
* fix: failing tests for domain parse util function

This commit fixes the updated domain parse util function (that uses
tldts) to make sure all tests pass.

* Revert "fix: failing tests for domain parse util function"

This reverts commit b7e0f8e.

* Fix issues with tldts not parsing private domains like ec2
  • Loading branch information
deepjyoti30-st authored Oct 1, 2024
1 parent 5aeab6a commit a59fa41
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/build/utils.js

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

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

let parsedURL = parse(hostname);
// Before `tldts`, `psl` was being used and that library automatically
// handled parsing private domains. With `tldts`, `allowPrivateDomains` is
// required to be passed to handle that.
//
// This is important for parsing ec2 public URL's that were initially
// reported to be breaking in the following issue:
// https://github.com/supertokens/supertokens-python/issues/394
let parsedURL = parse(hostname, { allowPrivateDomains: true });
if (!parsedURL.domain) {
// If the URL is an AWS public URL, return the entire URL since it is
// considered a suffix entirely (instead of just amazonaws.com). This
// was initially reported in https://github.com/supertokens/supertokens-python/issues/394
if (hostname.endsWith(".amazonaws.com") && parsedURL.publicSuffix === hostname) {
return hostname;
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

0 comments on commit a59fa41

Please sign in to comment.