diff --git a/app/browser/webtorrent.js b/app/browser/webtorrent.js index 7f08ba2e2be..30025973d93 100644 --- a/app/browser/webtorrent.js +++ b/app/browser/webtorrent.js @@ -3,6 +3,7 @@ const ipc = electron.ipcMain const appUrlUtil = require('../../js/lib/appUrlUtil') const messages = require('../../js/constants/messages') const Filtering = require('../filtering') +const url = require('url') // Set to see communication between WebTorrent and torrent viewer tabs const DEBUG_IPC = false @@ -60,7 +61,13 @@ function setupFiltering () { return {} } - var viewerUrl = getViewerURL(details.url) + const parsedUrl = url.parse(details.url) + const directDownload = parsedUrl && parsedUrl.query && parsedUrl.query.includes('download=true') + if (directDownload) { + return {} + } + + const viewerUrl = getViewerURL(details.url) return { responseHeaders: { diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index 71ec371b2b3..b900312526a 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -176,6 +176,7 @@ function saveTorrentFile () { let a = document.createElement('a') a.target = '_blank' a.download = true + a.href = `${store.torrentId}?download=true` a.href = store.torrentId a.click() }