From fbfe4a646ade0d46df934423ddfd1646de3b7191 Mon Sep 17 00:00:00 2001 From: Kasper Seweryn Date: Tue, 3 May 2022 12:06:37 +0200 Subject: [PATCH] Fix instanceUrl not being optional --- front/src/store/instance.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/front/src/store/instance.ts b/front/src/store/instance.ts index 738f88c84..579440dbd 100644 --- a/front/src/store/instance.ts +++ b/front/src/store/instance.ts @@ -9,7 +9,7 @@ export interface State { defaultServerUrl: string additionalStylesheets: string[] // TODO (wvffle): Ensure it's not nullable } - instanceUrl: string + instanceUrl?: string knownInstances: string[] nodeinfo: unknown | null // TODO (wvffle): Get nodeinfo type from swagger automatically settings: Settings @@ -132,7 +132,7 @@ const store: Module = { getters: { absoluteUrl: (state) => (relativeUrl: string) => { if (relativeUrl.startsWith('http')) return relativeUrl - if (state.instanceUrl.endsWith('/') && relativeUrl.startsWith('/')) { + if (state.instanceUrl?.endsWith('/') && relativeUrl.startsWith('/')) { relativeUrl = relativeUrl.slice(1) } @@ -140,6 +140,8 @@ const store: Module = { return instanceUrl + relativeUrl }, domain: (state) => { + if (!state.instanceUrl) return null + const url = state.instanceUrl const parser = document.createElement('a') parser.href = url