From 870dd893fc0ed94aa3bee250bf219e1c0b02178e Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Sun, 22 May 2016 07:23:16 +0800 Subject: [PATCH] Add support for pasting a `instant.io` link. (#559) Closes #547. --- renderer/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/renderer/index.js b/renderer/index.js index a790cecf..9f0bf2bc 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -605,6 +605,7 @@ function getTorrentSummary (torrentKey) { // Adds a torrent to the list, starts downloading/seeding. TorrentID can be a // magnet URI, infohash, or torrent file: https://github.com/feross/webtorrent#clientaddtorrentid-opts-function-ontorrent-torrent- +var instantIoRegex = /^(https:\/\/)?instant\.io\/#/ function addTorrent (torrentId) { backToList() var torrentKey = state.nextTorrentKey++ @@ -613,6 +614,10 @@ function addTorrent (torrentId) { // Use path string instead of W3C File object torrentId = torrentId.path } + // Allow a instant.io link to be pasted + if (typeof torrentId === 'string' && instantIoRegex.test(torrentId)) { + torrentId = torrentId.slice(torrentId.indexOf('#') + 1) + } ipcRenderer.send('wt-start-torrenting', torrentKey, torrentId, path) }