From a6da06a8efdb286eb390493c2d7177e642a18a16 Mon Sep 17 00:00:00 2001 From: Michael Clark <5285928+MikesGlitch@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:16:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Extra=20error=20handling=20for?= =?UTF-8?q?=20if=20user=20has=20incorrect=20server=20url=20(#3736)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * adding some safety for if user has incorrect server url format * added additional error handling for when incorrect server url has been setup * good rabbit --- .../loot-core/src/server/server-config.ts | 23 +++++++++++++------ upcoming-release-notes/3736.md | 6 +++++ 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 upcoming-release-notes/3736.md diff --git a/packages/loot-core/src/server/server-config.ts b/packages/loot-core/src/server/server-config.ts index 79f4933254e..df30b721f43 100644 --- a/packages/loot-core/src/server/server-config.ts +++ b/packages/loot-core/src/server/server-config.ts @@ -27,13 +27,22 @@ export function setServer(url: string): void { // `url` is optional; if not given it will provide the global config export function getServer(url?: string): ServerConfig | null { if (url) { - return { - BASE_SERVER: url, - SYNC_SERVER: joinURL(url, '/sync'), - SIGNUP_SERVER: joinURL(url, '/account'), - GOCARDLESS_SERVER: joinURL(url, '/gocardless'), - SIMPLEFIN_SERVER: joinURL(url, '/simplefin'), - }; + try { + return { + BASE_SERVER: url, + SYNC_SERVER: joinURL(url, '/sync'), + SIGNUP_SERVER: joinURL(url, '/account'), + GOCARDLESS_SERVER: joinURL(url, '/gocardless'), + SIMPLEFIN_SERVER: joinURL(url, '/simplefin'), + }; + } catch (error) { + console.warn( + 'Unable to parse server URL - using the global config.', + { config }, + error, + ); + return config; + } } return config; } diff --git a/upcoming-release-notes/3736.md b/upcoming-release-notes/3736.md new file mode 100644 index 00000000000..71d80fd35f7 --- /dev/null +++ b/upcoming-release-notes/3736.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MikesGlitch] +--- + +Add extra error handling for when an incorrect server URL has been setup