mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-08 11:56:59 +00:00
20 lines
723 B
JavaScript
20 lines
723 B
JavaScript
const API_BASE = window.location.origin;
|
|
|
|
export function emailAccountQuery(prefix = '&') {
|
|
const accountId = window.__odysseusActiveEmailAccount || '';
|
|
if (!accountId) return '';
|
|
const lead = prefix === '?' ? '?' : '&';
|
|
return `${lead}account_id=${encodeURIComponent(accountId)}`;
|
|
}
|
|
|
|
export function emailApiUrl(path, params = {}) {
|
|
const url = new URL(`${API_BASE}${path}`);
|
|
const accountId = window.__odysseusActiveEmailAccount || '';
|
|
if (accountId) url.searchParams.set('account_id', accountId);
|
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
if (value === undefined || value === null || value === '') return;
|
|
url.searchParams.set(key, String(value));
|
|
});
|
|
return url.toString();
|
|
}
|