tweak registerProtocolHandler API

This commit is contained in:
Feross Aboukhadijeh
2016-03-20 01:31:11 -07:00
parent b6bd9dbb70
commit c4a74c526d

View File

@@ -2,7 +2,7 @@ var config = require('../config')
module.exports = function () { module.exports = function () {
if (process.platform === 'win32') { if (process.platform === 'win32') {
registerProtocolHandler('magnet', 'BitTorrent Magnet URL', config.APP_FILE_ICON + '.ico', process.execPath) registerProtocolHandler('magnet', 'URL:BitTorrent Magnet URL', config.APP_FILE_ICON + '.ico', process.execPath)
registerFileHandler('.torrent', 'io.webtorrent.torrent', 'BitTorrent Document', config.APP_FILE_ICON + '.ico', process.execPath) registerFileHandler('.torrent', 'io.webtorrent.torrent', 'BitTorrent Document', config.APP_FILE_ICON + '.ico', process.execPath)
} }
} }
@@ -12,13 +12,15 @@ module.exports = function () {
* registry: * registry:
* *
* HKEY_CLASSES_ROOT * HKEY_CLASSES_ROOT
* $PROTOCOL * $PROTOCOL
* (Default) = "URL:$NAME" * (Default) = "$NAME"
* URL Protocol = "" * URL Protocol = ""
* shell * DefaultIcon
* open * (Default) = "$ICON"
* command * shell
* (Default) = "$COMMAND" "%1" * open
* command
* (Default) = "$COMMAND" "%1"
* *
* Source: https://msdn.microsoft.com/en-us/library/aa767914.aspx * Source: https://msdn.microsoft.com/en-us/library/aa767914.aspx
* *
@@ -34,7 +36,7 @@ function registerProtocolHandler (protocol, name, icon, command) {
hive: Registry.HKCU, // HKEY_CURRENT_USER hive: Registry.HKCU, // HKEY_CURRENT_USER
key: '\\Software\\Classes\\' + protocol key: '\\Software\\Classes\\' + protocol
}) })
protocolKey.set('', Registry.REG_SZ, 'URL:' + name, callback) protocolKey.set('', Registry.REG_SZ, name, callback)
protocolKey.set('URL Protocol', Registry.REG_SZ, '', callback) protocolKey.set('URL Protocol', Registry.REG_SZ, '', callback)
var iconKey = new Registry({ var iconKey = new Registry({