diff --git a/workspace/v19.0.0/workspace-platform-starter/common/views/contact/common/contacts.js b/workspace/v19.0.0/workspace-platform-starter/common/views/contact/common/contacts.js index 37d14d7fb8..4f60d53f2e 100644 --- a/workspace/v19.0.0/workspace-platform-starter/common/views/contact/common/contacts.js +++ b/workspace/v19.0.0/workspace-platform-starter/common/views/contact/common/contacts.js @@ -7,7 +7,9 @@ let avatarRoot = '../data/avatars/'; export async function initialize() { const customSettings = await getManifestCustomSettings(); - const response = await fetch(customSettings.contactsProvider?.url ?? '../data/contacts.json'); + const contactsProviderUrl = getContactsProviderUrl() ?? customSettings.contactsProvider?.url; + console.log(`contactsProviderUrl = ${contactsProviderUrl}`); + const response = await fetch(contactsProviderUrl ?? '../data/contacts.json'); avatarRoot = customSettings.contactsProvider?.avatarRoot ?? avatarRoot; @@ -93,3 +95,31 @@ async function getManifestCustomSettings() { } return {}; } + +/** + * Tries to get a url from the query string to override the contacts provider. + * @returns The contacts provider url if found. + */ +function getContactsProviderUrl() { + // Get the URL parameters + console.log("Attempting to get URL Params..."); + const urlParams = new URLSearchParams(window.location.search); + const contactsProviderUrl = urlParams.get('contactsProviderUrl'); + + if (!contactsProviderUrl) { + return; + } + + try { + const url = new URL(contactsProviderUrl); + const validDomains = ['openfin.github.io', 'built-on-openfin.github.io']; + + if (validDomains.includes(url.hostname)) { + console.log('Valid contactsProviderUrl override url provided:', contactsProviderUrl); + return url.href; + } + console.error('Invalid domain in contactsProviderUrl:', url.hostname); + } catch { + console.error('Invalid contactsProviderUrl URL:', contactsProviderUrl); + } +}