forked from premiere/premiere-libtorrent
add throwing overload of parse_magnet_uri
This commit is contained in:
parent
d2bf34632c
commit
a690e6c76d
|
@ -79,8 +79,10 @@ namespace libtorrent {
|
|||
#endif
|
||||
|
||||
// This function parses out information from the magnet link and populates the
|
||||
// add_torrent_params object.
|
||||
// add_torrent_params object. The overload that does not take an
|
||||
// ``error_code`` reference will throw a system_error on error
|
||||
TORRENT_EXPORT add_torrent_params parse_magnet_uri(string_view uri, error_code& ec);
|
||||
TORRENT_EXPORT add_torrent_params parse_magnet_uri(string_view uri);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -299,4 +299,12 @@ namespace libtorrent {
|
|||
if (!name.empty()) p.name = name;
|
||||
return p;
|
||||
}
|
||||
|
||||
add_torrent_params parse_magnet_uri(string_view uri)
|
||||
{
|
||||
error_code ec;
|
||||
add_torrent_params ret = parse_magnet_uri(uri, ec);
|
||||
if (ec) aux::throw_ex<system_error>(ec);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,6 +250,11 @@ TORRENT_TEST(parse_invalid_escaped_hash_parameter)
|
|||
TEST_EQUAL(ec, error_code(errors::invalid_escaped_string));
|
||||
}
|
||||
|
||||
TORRENT_TEST(throwing_overload)
|
||||
{
|
||||
TEST_THROW(parse_magnet_uri("magnet:?xt=urn%%3A"));
|
||||
}
|
||||
|
||||
TORRENT_TEST(parse_missing_hash)
|
||||
{
|
||||
// parse_magnet_uri
|
||||
|
|
Loading…
Reference in New Issue