From baee0ee40ca91bb43d0b3eed076195fd13ba7644 Mon Sep 17 00:00:00 2001 From: Michael Zetterberg Date: Wed, 7 May 2025 04:57:20 +0200 Subject: [PATCH] fix(SW-2116): add compatibility with unencoded RefId as input --- apps/scandic-web/utils/refId.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/scandic-web/utils/refId.ts b/apps/scandic-web/utils/refId.ts index 95a0aef05..e594b9fd9 100644 --- a/apps/scandic-web/utils/refId.ts +++ b/apps/scandic-web/utils/refId.ts @@ -9,7 +9,12 @@ export function calculateRefId(confirmationNumber: string, lastName: string) { } export function parseRefId(refId: string) { - const data = decrypt(refId) + // Some external systems that link to us do not encode the refId parameter + // properly, so we reverse the decoding of plus sign into spaces. + // Slash and equal sign are not decoded into anything, so no action needed. + // We only need to cater for those three (plus, slash, equals) as RefId is + // Base64 encoded which only has these three special characters. + const data = decrypt(refId.replace(/ /g, "+")) const parts = data.split(",") if (parts.length !== 2) { throw new Error("Invalid refId format")