1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 23:07:59 +00:00

Fix WebUI removing parameters from magnet links

Closes #10939
This commit is contained in:
Thomas Piccirello 2019-07-20 01:21:49 -07:00
parent 65dfec9acf
commit c17d653544
2 changed files with 10 additions and 12 deletions

View File

@ -967,18 +967,13 @@ function registerMagnetHandler() {
function handleDownloadParam() {
// Extract torrent URL from download param in WebUI URL hash
const hashParams = getHashParamsFromUrl();
const url = hashParams.download;
if (!url)
const downloadHash = "#download=";
if (location.hash.indexOf(downloadHash) !== 0)
return;
// Remove the download param from WebUI URL hash
delete hashParams.download;
let newHash = Object.toQueryString(hashParams);
newHash = newHash ? ('#' + newHash) : '';
history.replaceState('', document.title,
(location.pathname + location.search + newHash));
const url = location.hash.substring(downloadHash.length);
// Remove the processed hash from the URL
history.replaceState('', document.title, (location.pathname + location.search));
showDownloadPage([url]);
}

View File

@ -135,8 +135,11 @@ const initializeWindows = function() {
showDownloadPage = function(urls) {
const id = 'downloadPage';
let contentUrl = 'download.html';
if (urls && urls.length)
contentUrl += '?urls=' + urls.join("|");
if (urls && (urls.length > 0)) {
contentUrl += ('?urls=' + urls.map(function(url) {
return encodeURIComponent(url);
}).join("|"));
}
new MochaUI.Window({
id: id,