fix: correct bookingUrl for EU instance in API responses (#27046)
* fix: use WEBAPP_URL for booking URLs when domains differ For EU deployments where WEBAPP_URL (app.cal.eu) differs from WEBSITE_URL (cal.com), use WEBAPP_URL for non-org booking URLs. This fixes incorrect bookingUrl in API responses for EU instance. * Created new shared utility getTldPlus1 and updated code to use shared function instead of inline copy * use same comment
This commit is contained in:
1 parent
e7a69d68df
commit
bea542b310
4 files changed
+28
-12
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { CONSOLE_URL, WEBAPP_URL, WEBSITE_URL, EMBED_LIB_URL } from "@calcom/lib/constants";
|
||||
import { getTldPlus1 } from "@calcom/lib/getTldPlus1";
|
||||
|
||||
// It ensures that redirection URL safe where it is accepted through a query params or other means where user can change it.
|
||||
export const getSafeRedirectUrl = (url = "") => {
|
||||
@@ -46,10 +47,5 @@ export function isSafeUrlToLoadResourceFrom(urlString: string) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTldPlus1(hostname: string) {
|
||||
// Note: It doesn't support multipart tlds like .co.uk and thus makes only one part tld's safe like .com(and thus cal.com)
|
||||
// If we want to use it elsewhere as well(apart from embed/preview.ts) we must consider Public Suffix List
|
||||
return hostname.split(".").slice(-2).join(".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Note: It doesn't support multipart tlds like .co.uk and thus makes only one part tld's safe like .com(and thus cal.com)
|
||||
* If we want to use it elsewhere as well(apart from embed/preview.ts) we must consider Public Suffix List
|
||||
*/
|
||||
export function getTldPlus1(hostname: string): string {
|
||||
return hostname.split(".").slice(-2).join(".");
|
||||
}
|
||||
Reference in new issue
Block a user