From d0763b7c2d7f9e6525a3c6c8acfd615906b6fde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Wed, 20 Sep 2023 09:42:29 +0100 Subject: [PATCH] fix: Handle hoisting --- editor.planx.uk/src/airbrake.ts | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/editor.planx.uk/src/airbrake.ts b/editor.planx.uk/src/airbrake.ts index b0a47aa458..037362ec6b 100644 --- a/editor.planx.uk/src/airbrake.ts +++ b/editor.planx.uk/src/airbrake.ts @@ -3,6 +3,29 @@ import { isLiveEnv } from "utils"; export const logger = getErrorLogger(); +/** + * Checking a partial host can be unsafe, e.g. + * window.location.host.endsWith("gov.uk") + */ +const getEnvForAllowedHosts = (host: string) => { + switch (host) { + case "planningservices.newcastle.gov.uk": + case "planningservices.medway.gov.uk": + case "planningservices.doncaster.gov.uk": + case "planningservices.lambeth.gov.uk": + case "planningservices.southwark.gov.uk": + case "planningservices.buckinghamshire.gov.uk": + case "editor.planx.uk": + return "production" + + case "editor.planx.dev": + return "staging" + + default: + "pullrequest"; + } +} + function log(...args: any[]) { return process.env.SUPPRESS_LOGS ? () => { @@ -38,26 +61,3 @@ function getErrorLogger(): ErrorLogger { interface ErrorLogger { notify: (args: unknown) => void; } - -/** - * Checking a partial host can be unsafe, e.g. - * window.location.host.endsWith("gov.uk") - */ -const getEnvForAllowedHosts = (host: string) => { - switch (host) { - case "planningservices.newcastle.gov.uk": - case "planningservices.medway.gov.uk": - case "planningservices.doncaster.gov.uk": - case "planningservices.lambeth.gov.uk": - case "planningservices.southwark.gov.uk": - case "planningservices.buckinghamshire.gov.uk": - case "editor.planx.uk": - return "production" - - case "editor.planx.dev": - return "staging" - - default: - "pullrequest"; - } -}