Browse Source

Merge pull request #10941 from Piccirello/fix-webui-magnet-trackers

Fix WebUI removing parameters from magnet links
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
7da2d04898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/webui/www/private/download.html
  2. 15
      src/webui/www/private/scripts/client.js
  3. 7
      src/webui/www/private/scripts/mocha-init.js

5
src/webui/www/private/download.html

@ -142,9 +142,8 @@ @@ -142,9 +142,8 @@
const encodedUrls = new URI().getData('urls');
if (encodedUrls) {
const urls = [];
encodedUrls.split('|').each(function(url) {
urls.push(decodeURIComponent(url));
const urls = encodedUrls.split('|').map(function(url) {
return decodeURIComponent(url);
});
if (urls.length)

15
src/webui/www/private/scripts/client.js

@ -967,18 +967,13 @@ function registerMagnetHandler() { @@ -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]);
}

7
src/webui/www/private/scripts/mocha-init.js

@ -135,8 +135,11 @@ const initializeWindows = function() { @@ -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,

Loading…
Cancel
Save