From 4b016481684b12f0419c856dc8e157d5d5c8147d Mon Sep 17 00:00:00 2001 From: artrejo Date: Fri, 21 Jan 2022 16:54:31 -0800 Subject: [PATCH] fix e2e tests --- src/Utils/EndpointValidation.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Utils/EndpointValidation.ts b/src/Utils/EndpointValidation.ts index e184fcf5a..4b258eafc 100644 --- a/src/Utils/EndpointValidation.ts +++ b/src/Utils/EndpointValidation.ts @@ -1,8 +1,12 @@ export function validateEndpoint(endpointToValidate: string | undefined, allowedEndpoints: string[]): boolean { - if (!endpointToValidate) { - return true; + try { + return validateEndpointInternal(endpointToValidate, allowedEndpoints); + } catch { + return false; } +} +function validateEndpointInternal(endpointToValidate: string | undefined, allowedEndpoints: string[]): boolean { const originToValidate: string = new URL(endpointToValidate).origin; const allowedOrigins: string[] = allowedEndpoints.map((allowedEndpoint) => new URL(allowedEndpoint).origin) || []; const valid = allowedOrigins.indexOf(originToValidate) >= 0; @@ -33,7 +37,7 @@ export const allowedMongoProxyEndpoints: ReadonlyArray = [ "https://localhost:12901", ]; -export const allowedEmulatorEndpoints: ReadonlyArray = []; +export const allowedEmulatorEndpoints: ReadonlyArray = ["https://localhost:8081"]; export const allowedGraphEndpoints: ReadonlyArray = [];