From 2c77b0b90393c133d06d074ceb8b4e38c034a2d2 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 4 Feb 2009 17:53:58 +0100 Subject: Fixes: cpaster: make complete urls also acceptable. Details: also accept trailing slashes --- src/plugins/cpaster/cpasterplugin.cpp | 17 ++++++++++++++--- src/plugins/cpaster/cpasterplugin.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 4558ccaae8..28936dc62e 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -124,6 +124,16 @@ void CodepasterPlugin::extensionsInitialized() ->getObject(); } +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() { if (m_poster) @@ -171,7 +181,8 @@ void CodepasterPlugin::post() data = view.getContent(); // Submit to codepaster - m_poster = new CustomPoster(m_settingsPage->serverUrl().toString()); + + m_poster = new CustomPoster(serverUrl()); // Copied from cpaster. Otherwise lineendings will screw up if (!data.contains("\r\n")) { @@ -187,7 +198,7 @@ void CodepasterPlugin::fetch() { if (m_fetcher) delete m_fetcher; - m_fetcher = new CustomFetcher(m_settingsPage->serverUrl().toString()); + m_fetcher = new CustomFetcher(serverUrl()); QDialog dialog; Ui_PasteSelectDialog ui; @@ -208,7 +219,7 @@ void CodepasterPlugin::fetch() return; delete m_fetcher; - m_fetcher = new CustomFetcher(m_settingsPage->serverUrl().toString()); + m_fetcher = new CustomFetcher(serverUrl()); m_fetcher->fetch(pasteID); } diff --git a/src/plugins/cpaster/cpasterplugin.h b/src/plugins/cpaster/cpasterplugin.h index 56c41144a9..3658169c6c 100644 --- a/src/plugins/cpaster/cpasterplugin.h +++ b/src/plugins/cpaster/cpasterplugin.h @@ -70,6 +70,7 @@ public slots: void fetch(); private: + QString serverUrl() const; QAction *m_postAction; QAction *m_fetchAction; -- cgit v1.2.3