Skip to content
Snippets Groups Projects
Commit 38d99063 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

CodePaster[CodePaster]: Allow for fetching complete URLs.


Reviewed-by: default avatarTobias Hunger <qt-info@nokia.com>
Task-number: QTCREATORBUG-2542
parent ed6f2852
No related branches found
No related tags found
No related merge requests found
...@@ -99,13 +99,24 @@ void CodePasterProtocol::fetch(const QString &id) ...@@ -99,13 +99,24 @@ void CodePasterProtocol::fetch(const QString &id)
QTC_ASSERT(!m_fetchReply, return; ) QTC_ASSERT(!m_fetchReply, return; )
QString hostName = m_page->hostName(); QString hostName = m_page->hostName();
QString link = "http://"; const QString httpPrefix = "http://";
link.append(hostName); QString link;
link.append("/?format=raw&id="); // Did the user enter a complete URL instead of an id?
link.append(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); m_fetchReply = httpGet(link);
connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished())); connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
m_fetchId = id;
} }
void CodePasterProtocol::list() void CodePasterProtocol::list()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment