Add support for opening file:// urls (#2311)

* Add support for opening file:// urls
* Open file urls without file:// scheme
This commit is contained in:
Weslly
2018-09-21 00:49:56 -03:00
committed by Jonathan White
parent 341635f6bd
commit f8b997bcf4
2 changed files with 20 additions and 6 deletions

View File

@@ -148,6 +148,8 @@ void TestEntry::testResolveUrl()
QScopedPointer<Entry> entry(new Entry());
QString testUrl("www.google.com");
QString testCmd("cmd://firefox " + testUrl);
QString testFileUnix("/home/example/test.txt");
QString testFileWindows("c:/WINDOWS/test.txt");
QString testComplexCmd("cmd://firefox --start-now --url 'http://" + testUrl + "' --quit");
QString nonHttpUrl("ftp://google.com");
QString noUrl("random text inserted here");
@@ -156,6 +158,11 @@ void TestEntry::testResolveUrl()
QCOMPARE(entry->resolveUrl(""), QString(""));
QCOMPARE(entry->resolveUrl(testUrl), "https://" + testUrl);
QCOMPARE(entry->resolveUrl("http://" + testUrl), "http://" + testUrl);
// Test file:// URL's
QCOMPARE(entry->resolveUrl("file://" + testFileUnix), "file://" + testFileUnix);
QCOMPARE(entry->resolveUrl(testFileUnix), "file://" + testFileUnix);
QCOMPARE(entry->resolveUrl("file:///" + testFileWindows), "file:///" + testFileWindows);
QCOMPARE(entry->resolveUrl(testFileWindows), "file:///" + testFileWindows);
// Test cmd:// with no URL
QCOMPARE(entry->resolveUrl("cmd://firefox"), QString(""));
QCOMPARE(entry->resolveUrl("cmd://firefox --no-url"), QString(""));