forked from premiere/premiere-libtorrent
add trailing slash (#1969)
This commit is contained in:
parent
76ef0babed
commit
11c75da314
|
@ -53,6 +53,11 @@ namespace libtorrent {
|
|||
// internal
|
||||
inline bool is_digit(char c)
|
||||
{ return c >= '0' && c <= '9'; }
|
||||
inline void ensure_trailing_slash(std::string& url)
|
||||
{
|
||||
if (url.empty() || url[url.size() - 1] != '/')
|
||||
url += '/';
|
||||
}
|
||||
|
||||
TORRENT_EXTRA_EXPORT bool is_print(char c);
|
||||
TORRENT_EXTRA_EXPORT bool is_space(char c);
|
||||
|
|
|
@ -121,8 +121,7 @@ namespace libtorrent {
|
|||
// however, we may still need to insert a '/' in case neither side
|
||||
// has one. We know the location doesn't start with a / already.
|
||||
// so, if the referrer doesn't end with one, add it.
|
||||
if (url.empty() || url[url.size() - 1] != '/')
|
||||
url += '/';
|
||||
ensure_trailing_slash(url);
|
||||
url += location;
|
||||
}
|
||||
return url;
|
||||
|
|
|
@ -265,7 +265,8 @@ namespace libtorrent {
|
|||
|
||||
// correct URLs to end with a "/" for multi-file torrents
|
||||
std::string& url = ws.back().url;
|
||||
if (multi_file && url[url.size()-1] != '/') url += '/';
|
||||
if (multi_file)
|
||||
ensure_trailing_slash(url);
|
||||
}
|
||||
|
||||
for (auto const& e : p.http_seeds)
|
||||
|
|
|
@ -1460,7 +1460,8 @@ namespace libtorrent {
|
|||
{
|
||||
web_seed_entry ent(maybe_url_encode(url_seeds.string_value().to_string())
|
||||
, web_seed_entry::url_seed);
|
||||
if ((m_flags & multifile) && ent.url[ent.url.size() - 1] != '/') ent.url += '/';
|
||||
if (m_flags & multifile)
|
||||
ensure_trailing_slash(ent.url);
|
||||
m_web_seeds.push_back(ent);
|
||||
}
|
||||
else if (url_seeds && url_seeds.type() == bdecode_node::list_t)
|
||||
|
@ -1474,7 +1475,8 @@ namespace libtorrent {
|
|||
if (url.string_length() == 0) continue;
|
||||
web_seed_entry ent(maybe_url_encode(url.string_value().to_string())
|
||||
, web_seed_entry::url_seed);
|
||||
if ((m_flags & multifile) && ent.url[ent.url.size() - 1] != '/') ent.url += '/';
|
||||
if (m_flags & multifile)
|
||||
ensure_trailing_slash(ent.url);
|
||||
if (!unique.insert(ent.url).second) continue;
|
||||
m_web_seeds.push_back(ent);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
|
|||
{
|
||||
// handle incorrect .torrent files which are multi-file
|
||||
// but have web seeds not ending with a slash
|
||||
if (m_path.empty() || m_path[m_path.size() - 1] != '/') m_path += '/';
|
||||
if (m_url.empty() || m_url[m_url.size() - 1] != '/') m_url += '/';
|
||||
ensure_trailing_slash(m_path);
|
||||
ensure_trailing_slash(m_url);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue