forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Hotfix/Orgs rewrite causing 404 with 3 or more dots domains (ca…
…lcom#9803) * Fix RegExp * Used ORGANIZATIONS_ENABLED to opt-out of orgs behaviour * Add comments * Add a new testcase * Add response headers for easier debugging and Checkly tests in production
- Loading branch information
1 parent
66d4797
commit 8384c3f
Showing
4 changed files
with
131 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const getDefaultSubdomain = (url) => { | ||
if (!url.startsWith("http:") && !url.startsWith("https:")) { | ||
// Make it a valid URL. Mabe we can simply return null and opt-out from orgs support till the use a URL scheme. | ||
url = `https://${url}`; | ||
} | ||
const _url = new URL(url); | ||
const regex = new RegExp(/^([a-z]+\:\/{2})?((?<subdomain>[\w-.]+)\.[\w-]+\.\w+)$/); | ||
//console.log(_url.hostname, _url.hostname.match(regex)); | ||
return _url.hostname.match(regex)?.groups?.subdomain || null; | ||
}; | ||
exports.getSubdomainRegExp = (url) => { | ||
const defaultSubdomain = getDefaultSubdomain(url); | ||
const subdomain = defaultSubdomain ? `(?!${defaultSubdomain})[^.]+` : "[^.]+"; | ||
return subdomain; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters