Skip to content

Commit

Permalink
Update native OIDC callback url to be RFC8252 compliant
Browse files Browse the repository at this point in the history
By switching the double slash for a single one

Fixes element-hq/element-desktop#1889

Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Sep 24, 2024
1 parent 787feca commit 994fcd6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vector/platform/ElectronPlatform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 994fcd6

Please sign in to comment.