Skip to content

Commit

Permalink
Fix issues with tldts not parsing private domains like ec2
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Oct 1, 2024
1 parent 1e93a05 commit 352e58a
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 352e58a

Please sign in to comment.