Skip to content
Snippets Groups Projects
Commit 2c77b0b9 authored by hjk's avatar hjk
Browse files

Fixes: cpaster: make complete urls also acceptable.

    Details:  also accept trailing slashes
parent 50661f99
No related branches found
No related tags found
No related merge requests found
...@@ -124,6 +124,16 @@ void CodepasterPlugin::extensionsInitialized() ...@@ -124,6 +124,16 @@ void CodepasterPlugin::extensionsInitialized()
->getObject<ProjectExplorer::ProjectExplorerPlugin>(); ->getObject<ProjectExplorer::ProjectExplorerPlugin>();
} }
QString CodepasterPlugin::serverUrl() const
{
QString url = m_settingsPage->serverUrl().toString();
if (url.startsWith("http://"))
url = url.mid(7);
if (url.endsWith('/'))
url.chop(1);
return url;
}
void CodepasterPlugin::post() void CodepasterPlugin::post()
{ {
if (m_poster) if (m_poster)
...@@ -171,7 +181,8 @@ void CodepasterPlugin::post() ...@@ -171,7 +181,8 @@ void CodepasterPlugin::post()
data = view.getContent(); data = view.getContent();
// Submit to codepaster // Submit to codepaster
m_poster = new CustomPoster(m_settingsPage->serverUrl().toString());
m_poster = new CustomPoster(serverUrl());
// Copied from cpaster. Otherwise lineendings will screw up // Copied from cpaster. Otherwise lineendings will screw up
if (!data.contains("\r\n")) { if (!data.contains("\r\n")) {
...@@ -187,7 +198,7 @@ void CodepasterPlugin::fetch() ...@@ -187,7 +198,7 @@ void CodepasterPlugin::fetch()
{ {
if (m_fetcher) if (m_fetcher)
delete m_fetcher; delete m_fetcher;
m_fetcher = new CustomFetcher(m_settingsPage->serverUrl().toString()); m_fetcher = new CustomFetcher(serverUrl());
QDialog dialog; QDialog dialog;
Ui_PasteSelectDialog ui; Ui_PasteSelectDialog ui;
...@@ -208,7 +219,7 @@ void CodepasterPlugin::fetch() ...@@ -208,7 +219,7 @@ void CodepasterPlugin::fetch()
return; return;
delete m_fetcher; delete m_fetcher;
m_fetcher = new CustomFetcher(m_settingsPage->serverUrl().toString()); m_fetcher = new CustomFetcher(serverUrl());
m_fetcher->fetch(pasteID); m_fetcher->fetch(pasteID);
} }
......
...@@ -70,6 +70,7 @@ public slots: ...@@ -70,6 +70,7 @@ public slots:
void fetch(); void fetch();
private: private:
QString serverUrl() const;
QAction *m_postAction; QAction *m_postAction;
QAction *m_fetchAction; QAction *m_fetchAction;
......
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