From b38fdf49ad4239e785dc1a88f485c74e9316c413 Mon Sep 17 00:00:00 2001 From: evlist Date: Sat, 15 Apr 2023 17:29:50 +0200 Subject: [PATCH] Check db url before attempting to get a user id. --- src/lib/user-id.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/user-id.ts b/src/lib/user-id.ts index 826ef10..0de9416 100644 --- a/src/lib/user-id.ts +++ b/src/lib/user-id.ts @@ -32,5 +32,9 @@ export const parseDbUrl = (urlString: string) => { return { username: hex2a(encodedUser), database: urlString }; }; -export const dbUrlToUserId = (urlString: string) => - userId(parseDbUrl(urlString)); +export const dbUrlToUserId = (urlString: string) => { + if (!urlString) { + return null; + } + return userId(parseDbUrl(urlString)); +};