Skip to content

A full-featured download manager.

refactor: merge magnet & thunder protocol handling

thecodrre2338757de7b
diff --git a/src/main/core/ProtocolManager.js b/src/main/core/ProtocolManager.js
index 2f7a1021..5cbe0d7d 100644
--- a/src/main/core/ProtocolManager.js
+++ b/src/main/core/ProtocolManager.js
@@ -41,13 +41,7 @@ export default class ProtocolManager extends EventEmitter {
handle (url) {
logger.info(`[Motrix] protocol url: ${url}`)
- if (url.toLowerCase().startsWith('magnet:')) {
- return this.handleMagnetProtocol(url)
- }
-
- if (url.toLowerCase().startsWith('thunder:')) {
- return this.handleThunderProtocol(url)
- }
+ this.handleMagnetAndThunderProtocol(url)
if (
url.toLowerCase().startsWith('mo:') ||
@@ -57,20 +51,21 @@ export default class ProtocolManager extends EventEmitter {
}
}
- handleMagnetProtocol (url) {
+ handleMagnetAndThunderProtocol (url) {
if (!url) {
return
}
- logger.error(`[Motrix] handleMagnetProtocol url: ${url}`)
-
- global.application.sendCommandToAll('application:new-task', 'uri', url)
- }
+ let protocolTag = "";
+
+ if (url.toLowerCase().startsWith('magnet:')) {
+ protocolTag = "handleMagnetProtocol";
+ }
- handleThunderProtocol (url) {
- if (!url) {
- return
+ if (url.toLowerCase().startsWith('thunder:')) {
+ protocolTag = "handleThunderProtocol";
}
- logger.error(`[Motrix] handleThunderProtocol url: ${url}`)
+
+ logger.error(`[Motrix] ${protocolTag} url: ${url}`)
global.application.sendCommandToAll('application:new-task', 'uri', url)
}