|
| 1 | +diff --git a/packages/shared/lib/helpers/url.ts b/packages/shared/lib/helpers/url.ts |
| 2 | +index 11cd310f6..8019c07f5 100644 |
| 3 | +--- a/packages/shared/lib/helpers/url.ts |
| 4 | ++++ b/packages/shared/lib/helpers/url.ts |
| 5 | +@@ -175,48 +175,16 @@ export const getSecondLevelDomain = (hostname: string) => { |
| 6 | + return hostname.slice(hostname.indexOf('.') + 1); |
| 7 | + }; |
| 8 | + |
| 9 | +-export const getRelativeApiHostname = (hostname: string) => { |
| 10 | +- const idx = hostname.indexOf('.'); |
| 11 | +- const first = hostname.slice(0, idx); |
| 12 | +- const second = hostname.slice(idx + 1); |
| 13 | +- return `${first}-api.${second}`; |
| 14 | +-}; |
| 15 | +- |
| 16 | + export const getIsDohDomain = (origin: string) => { |
| 17 | + return DOH_DOMAINS.some((dohDomain) => origin.endsWith(dohDomain)); |
| 18 | + }; |
| 19 | + |
| 20 | + export const getApiSubdomainUrl = (pathname: string) => { |
| 21 | +- const url = new URL('/', window.location.origin); |
| 22 | +- if (url.hostname === 'localhost' || getIsDohDomain(url.origin)) { |
| 23 | +- url.pathname = `/api${pathname}`; |
| 24 | +- return url; |
| 25 | +- } |
| 26 | +- url.hostname = getRelativeApiHostname(url.hostname); |
| 27 | ++ const url = new URL('/', '___ELECTRON_MAIL_PROTON_API_ENTRY_URL_PLACEHOLDER___'); |
| 28 | + url.pathname = pathname; |
| 29 | + return url; |
| 30 | + }; |
| 31 | + |
| 32 | +-export const getAppUrlFromApiUrl = (apiUrl: string, appName: APP_NAMES) => { |
| 33 | +- const { subdomain } = APPS_CONFIGURATION[appName]; |
| 34 | +- const url = new URL(apiUrl); |
| 35 | +- const { hostname } = url; |
| 36 | +- const index = hostname.indexOf('.'); |
| 37 | +- const tail = hostname.slice(index + 1); |
| 38 | +- url.pathname = ''; |
| 39 | +- url.hostname = `${subdomain}.${tail}`; |
| 40 | +- return url; |
| 41 | +-}; |
| 42 | +- |
| 43 | +-export const getAppUrlRelativeToOrigin = (origin: string, appName: APP_NAMES) => { |
| 44 | +- const { subdomain } = APPS_CONFIGURATION[appName]; |
| 45 | +- const url = new URL(origin); |
| 46 | +- const segments = url.host.split('.'); |
| 47 | +- segments[0] = subdomain; |
| 48 | +- url.hostname = segments.join('.'); |
| 49 | +- return url; |
| 50 | +-}; |
| 51 | +- |
| 52 | + let cache = ''; |
| 53 | + export const getStaticURL = (path: string) => { |
| 54 | + if (window.location.hostname === 'localhost' || getIsDohDomain(window.location.origin)) { |
| 55 | + |
| 56 | +diff --git a/packages/shared/lib/fetch/helpers.ts b/packages/shared/lib/fetch/helpers.ts |
| 57 | +index f0b3e2e31..90995e1fc 100644 |
| 58 | +--- a/packages/shared/lib/fetch/helpers.ts |
| 59 | ++++ b/packages/shared/lib/fetch/helpers.ts |
| 60 | +@@ -10,6 +10,7 @@ const appendQueryParams = (url: URL, params: { [key: string]: any }) => { |
| 61 | + }); |
| 62 | + }; |
| 63 | + |
| 64 | ++/* <electron-mail-mark> */ |
| 65 | + export const createUrl = (urlString: string, params: { [key: string]: any } = {}) => { |
| 66 | + let url: URL; |
| 67 | + if (typeof window !== 'undefined') { |
| 68 | +@@ -20,6 +21,7 @@ export const createUrl = (urlString: string, params: { [key: string]: any } = {} |
| 69 | + appendQueryParams(url, params); |
| 70 | + return url; |
| 71 | + }; |
| 72 | ++/* </electron-mail-mark> */ |
| 73 | + |
| 74 | + export const checkStatus = (response: Response, config: any) => { |
| 75 | + const { status } = response; |
0 commit comments