Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failing tests for domain parse util function #931

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading