mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Merge pull request #10941 from Piccirello/fix-webui-magnet-trackers
Fix WebUI removing parameters from magnet links
This commit is contained in:
commit
7da2d04898
@ -142,9 +142,8 @@
|
|||||||
|
|
||||||
const encodedUrls = new URI().getData('urls');
|
const encodedUrls = new URI().getData('urls');
|
||||||
if (encodedUrls) {
|
if (encodedUrls) {
|
||||||
const urls = [];
|
const urls = encodedUrls.split('|').map(function(url) {
|
||||||
encodedUrls.split('|').each(function(url) {
|
return decodeURIComponent(url);
|
||||||
urls.push(decodeURIComponent(url));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (urls.length)
|
if (urls.length)
|
||||||
|
@ -967,18 +967,13 @@ function registerMagnetHandler() {
|
|||||||
|
|
||||||
function handleDownloadParam() {
|
function handleDownloadParam() {
|
||||||
// Extract torrent URL from download param in WebUI URL hash
|
// Extract torrent URL from download param in WebUI URL hash
|
||||||
const hashParams = getHashParamsFromUrl();
|
const downloadHash = "#download=";
|
||||||
const url = hashParams.download;
|
if (location.hash.indexOf(downloadHash) !== 0)
|
||||||
if (!url)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove the download param from WebUI URL hash
|
const url = location.hash.substring(downloadHash.length);
|
||||||
delete hashParams.download;
|
// Remove the processed hash from the URL
|
||||||
let newHash = Object.toQueryString(hashParams);
|
history.replaceState('', document.title, (location.pathname + location.search));
|
||||||
newHash = newHash ? ('#' + newHash) : '';
|
|
||||||
history.replaceState('', document.title,
|
|
||||||
(location.pathname + location.search + newHash));
|
|
||||||
|
|
||||||
showDownloadPage([url]);
|
showDownloadPage([url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +135,11 @@ const initializeWindows = function() {
|
|||||||
showDownloadPage = function(urls) {
|
showDownloadPage = function(urls) {
|
||||||
const id = 'downloadPage';
|
const id = 'downloadPage';
|
||||||
let contentUrl = 'download.html';
|
let contentUrl = 'download.html';
|
||||||
if (urls && urls.length)
|
if (urls && (urls.length > 0)) {
|
||||||
contentUrl += '?urls=' + urls.join("|");
|
contentUrl += ('?urls=' + urls.map(function(url) {
|
||||||
|
return encodeURIComponent(url);
|
||||||
|
}).join("|"));
|
||||||
|
}
|
||||||
|
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: id,
|
id: id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user