Commit 38d99063 authored by Friedemann Kleint's avatar Friedemann Kleint

CodePaster[CodePaster]: Allow for fetching complete URLs.

Reviewed-by: default avatarTobias Hunger <qt-info@nokia.com>
Task-number: QTCREATORBUG-2542
parent ed6f2852
......@@ -99,13 +99,24 @@ void CodePasterProtocol::fetch(const QString &id)
QTC_ASSERT(!m_fetchReply, return; )
QString hostName = m_page->hostName();
QString link = "http://";
link.append(hostName);
link.append("/?format=raw&id=");
link.append(id);
const QString httpPrefix = "http://";
QString link;
// Did the user enter a complete URL instead of an id?
if (id.startsWith(httpPrefix)) {
// Append 'raw' format option
link = id;
link += QLatin1String("&format=raw");
const int idPos = id.lastIndexOf(QLatin1Char('='));
m_fetchId = idPos != -1 ? id.mid(idPos + 1) : id;
} else {
link = httpPrefix;
link.append(hostName);
link.append("/?format=raw&id=");
link.append(id);
m_fetchId = id;
}
m_fetchReply = httpGet(link);
connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
m_fetchId = id;
}
void CodePasterProtocol::list()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment