Merge pull request #28096 from element-hq/t3chguy/fix/d1889

Update native OIDC callback url to be RFC8252 compliant
pull/28101/head
Michael Telatynski 2024-09-25 10:08:49 +00:00 committed by GitHub
commit 861ac3b50c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -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;
}
}