From 994fcd631900b0307cb47e8d44d5fda25f4e04a5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 24 Sep 2024 16:56:08 +0100 Subject: [PATCH] Update native OIDC callback url to be RFC8252 compliant By switching the double slash for a single one Fixes https://github.com/element-hq/element-desktop/issues/1889 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index af75347b7bb..0f650e7dbb8 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -472,6 +472,12 @@ export default class ElectronPlatform extends VectorBasePlatform { public getOidcCallbackUrl(): URL { const url = super.getOidcCallbackUrl(); url.protocol = "io.element.desktop"; + // Trim the double slash into a single slash to comply with https://datatracker.ietf.org/doc/html/rfc8252#section-7.1 + // Chrome seems to have a strange issue where non-standard protocols prevent URL object mutations on pathname + // field, so we cannot mutate `pathname` reliably and instead have to rewrite the href manually. + if (url.pathname.startsWith("//")) { + url.href = url.href.replace(url.pathname, url.pathname.slice(1)); + } return url; } }