Simplify CryptPad URLs

This commit is contained in:
Wolfgang Ginolas 2023-11-16 10:23:22 +01:00
parent 3d022013aa
commit 4924c8664a
1 changed files with 3 additions and 2 deletions

View File

@ -130,15 +130,16 @@ define([
const url = new URL(src);
const params = new URLSearchParams();
params.set('type', type);
params.set('protocol', url.protocol);
url.search = params.toString();
url.protocol = url.protocol === 'https:' ? 'cryptpads:' : 'cryptpad:';
url.protocol = 'cryptpad:';
url.hash = key;
return url.href;
};
const parseCryptPadUrl = function(href) {
const url = new URL(href);
url.protocol = url.protocol === 'cryptpads:' ? 'https:' : 'http:';
url.protocol = url.searchParams.get('protocol');
const key = url.hash.substring(1); // remove leading '#'
const type = url.searchParams.get('type');
url.search = '';