mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
LocationBar: Fix transforming text to url when searching is disabled
Closes #2578
This commit is contained in:
parent
efe806e65e
commit
1c4937b64c
|
@ -21,6 +21,7 @@
|
|||
#include "searchenginesmanager.h"
|
||||
#include "bookmarks.h"
|
||||
#include "bookmarkitem.h"
|
||||
#include "qzsettings.h"
|
||||
|
||||
static void removeBookmarks(BookmarkItem *parent)
|
||||
{
|
||||
|
@ -173,4 +174,36 @@ void LocationBarTest::loadActionSpecialSchemesTest()
|
|||
QCOMPARE(action.loadRequest.url(), QUrl("about:blank"));
|
||||
}
|
||||
|
||||
void LocationBarTest::loadAction_issue2578()
|
||||
{
|
||||
// typed text is not correctly transformed to QUrl when searchFromAddressBar is disabled
|
||||
|
||||
qzSettings->searchFromAddressBar = false;
|
||||
|
||||
LocationBar::LoadAction action;
|
||||
|
||||
action = LocationBar::loadAction("github.com");
|
||||
QCOMPARE(action.type, LocationBar::LoadAction::Url);
|
||||
QCOMPARE(action.loadRequest.url(), QUrl("http://github.com"));
|
||||
|
||||
action = LocationBar::loadAction("github");
|
||||
QCOMPARE(action.type, LocationBar::LoadAction::Url);
|
||||
QCOMPARE(action.loadRequest.url(), QUrl("http://github"));
|
||||
|
||||
action = LocationBar::loadAction("github/test/path");
|
||||
QCOMPARE(action.type, LocationBar::LoadAction::Url);
|
||||
QCOMPARE(action.loadRequest.url(), QUrl("http://github/test/path"));
|
||||
|
||||
action = LocationBar::loadAction("localhost");
|
||||
QCOMPARE(action.type, LocationBar::LoadAction::Url);
|
||||
QCOMPARE(action.loadRequest.url(), QUrl("http://localhost"));
|
||||
|
||||
action = LocationBar::loadAction("localhost/test/path");
|
||||
QCOMPARE(action.type, LocationBar::LoadAction::Url);
|
||||
QCOMPARE(action.loadRequest.url(), QUrl("http://localhost/test/path"));
|
||||
|
||||
action = LocationBar::loadAction("github.com foo bar");
|
||||
QCOMPARE(action.type, LocationBar::LoadAction::Invalid);
|
||||
}
|
||||
|
||||
FALKONTEST_MAIN(LocationBarTest)
|
||||
|
|
|
@ -33,4 +33,5 @@ private slots:
|
|||
void loadActionSearchTest();
|
||||
void loadAction_kdebug389491();
|
||||
void loadActionSpecialSchemesTest();
|
||||
void loadAction_issue2578();
|
||||
};
|
||||
|
|
|
@ -243,8 +243,11 @@ LocationBar::LoadAction LocationBar::loadAction(const QString &text)
|
|||
}
|
||||
|
||||
if (!qzSettings->searchFromAddressBar) {
|
||||
action.type = LoadAction::Url;
|
||||
action.loadRequest = QUrl(t);
|
||||
const QUrl &guessedUrl = QUrl::fromUserInput(t);
|
||||
if (guessedUrl.isValid()) {
|
||||
action.type = LoadAction::Url;
|
||||
action.loadRequest = guessedUrl;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user