From 9591d3b74ce0e0bfc68d698b143acfedf890ce5b Mon Sep 17 00:00:00 2001 From: Marcin S Date: Mon, 20 Dec 2021 15:45:12 -0600 Subject: [PATCH] Address review comments --- src/mysky/index.ts | 2 +- src/mysky/utils.ts | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mysky/index.ts b/src/mysky/index.ts index 123b5fb9..d1411f69 100644 --- a/src/mysky/index.ts +++ b/src/mysky/index.ts @@ -885,7 +885,7 @@ export class MySky { } // Call the `onUserLogin` hook for all DACs. - await Promise.all( + await Promise.allSettled( this.dacs.map(async (dac) => { try { await dac.onUserLogin(); diff --git a/src/mysky/utils.ts b/src/mysky/utils.ts index 83f64831..635c3ba5 100644 --- a/src/mysky/utils.ts +++ b/src/mysky/utils.ts @@ -16,7 +16,6 @@ export async function getFullDomainUrl(this: SkynetClient, domain: string): Prom return getFullDomainUrlForPortal(portalUrl, domain); } -// TODO: unit test /** * Gets the URL for the current skapp on the preferred portal, if we're not on * the preferred portal already. @@ -97,8 +96,8 @@ export function popupCenter(url: string, winName: string, w: number, h: number): * @returns - Whether the two URLs are equal for the purposes of redirecting. */ export function shouldRedirectToPreferredPortalUrl(currentPortalUrl: string, preferredPortalUrl: string): boolean { - currentPortalUrl = currentPortalUrl.split("//", 2)[1] || currentPortalUrl; - preferredPortalUrl = preferredPortalUrl.split("//", 2)[1] || preferredPortalUrl; - - return trimSuffix(currentPortalUrl, "/") === trimSuffix(preferredPortalUrl, "/"); + // Strip protocol and trailing slash (case-insensitive). + currentPortalUrl = trimSuffix(currentPortalUrl.replace(/https:\/\/|http:\/\//i, ""), "/"); + preferredPortalUrl = trimSuffix(preferredPortalUrl.replace(/https:\/\/|http:\/\//i, ""), "/"); + return currentPortalUrl === preferredPortalUrl; }