Skip to content

Commit

Permalink
Deploying to gh-pages from @ 4c1ebb5 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
johnman committed Jul 26, 2024
1 parent 5e72e21 commit 60b603b
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 60b603b

Please sign in to comment.