Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement exact source (xs) for magnet URIs #799
Conversation
1bfa128
to
0b814ae
| try { | ||
| this._xsRequest = get.concat(opts, function (err, res, torrent) { | ||
| if (err || !torrent.length) return | ||
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Just took a quick look. Looks pretty good to me. I don't think we to/can easily support ftp:// so I would remove that test case. |
This comment has been minimized.
This comment has been minimized.
|
Fixed.
I added that mainly to check if unsupported protocols would crash the process, since the spec says to silently ignore. |
This comment has been minimized.
This comment has been minimized.
|
I think we should check for http:// https:// explicitly before passing into |
This comment has been minimized.
This comment has been minimized.
|
Done.
For the protocol case yeah, just hope there's nothing else |
ef86e35
to
8288c3b
This comment has been minimized.
This comment has been minimized.
|
Okay, also migrated the tests over to a local server and reused the fixtures from |
2162641
to
9b2335a
This comment has been minimized.
This comment has been minimized.
|
Thanks -- will take a look after getting WebTorrent Desktop v0.5 out. |
This comment has been minimized.
This comment has been minimized.
|
I just checked the malformed URL case some more - a URL like |
|
|
||
| if (parsedTorrent.xs && !self.info) { | ||
| // TODO: Could try multiple in parallel here | ||
| var src = parsedTorrent.xs instanceof Array ? parsedTorrent.xs[0] : parsedTorrent.xs |
This comment has been minimized.
This comment has been minimized.
| } | ||
| } | ||
| this._xsRequest = get.concat(opts, function (err, res, torrent) { | ||
| if (err || res.statusCode !== 200 || !torrent.length) return |
This comment has been minimized.
This comment has been minimized.
feross
May 19, 2016
Member
No need to check for !torrent.length since that will make parseTorrent throw below anyway.
This comment has been minimized.
This comment has been minimized.
|
|
||
| if (parsedTorrent) { | ||
| if (parsedTorrent.infoHash !== self.infoHash) { | ||
| return |
This comment has been minimized.
This comment has been minimized.
| if (self._xsRequest) { | ||
| self._xsRequest.abort() | ||
| self._xsRequest = null | ||
| } |
This comment has been minimized.
This comment has been minimized.
|
|
||
| createServer(fixtures.leaves.torrent, function (url, next) { | ||
| client.add(fixtures.leaves.magnetURI + '&xs=' + encodeURIComponent(url), function (torrent) { | ||
| t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub') |
This comment has been minimized.
This comment has been minimized.
feross
May 19, 2016
Member
The name is also in the magnet URI as the &dn parameter. Might be better to check for another parameter.
| var client = new WebTorrent({ dht: false, tracker: false }) | ||
| client.add(fixtures.leaves.magnetURI + '&xs=' + encodeURIComponent('invalidurl:example')) | ||
| setTimeout(function () { | ||
| t.ok(true, 'no crash') |
This comment has been minimized.
This comment has been minimized.
feross
May 19, 2016
Member
No need for this. The tests will fail if there's a thrown exception. We should add listeners for 'error' and 'warning' events to all these tests though.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I totally fixed all of those just now Also what about the try-catch situation with malformed urls? |
This comment has been minimized.
This comment has been minimized.
|
Ah, thanks. I'm fixing all that up too. Sorry, should have communicated that better. |
This comment has been minimized.
This comment has been minimized.
|
I'm adding support for multiple &xs= params too. |
- Support multiple &xs= params in parallel - Fail on 'error' 'warning' events
This comment has been minimized.
This comment has been minimized.
|
@Sebmaster See #809 |
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
May 4, 2018
|
This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue. |
Sebmaster commentedMay 13, 2016
Since I saw #714 stalled a bit, I wanted to check in if no one's working on this and started off with a minimal working prototype.
I know I still need to move the fixture over (also don't rely on webtorrent.io, but create a local server instead) to the other repo, but does this look okay / is anyone else working on this?