summaryrefslogtreecommitdiff
path: root/src/application.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/application.cpp')
-rw-r--r--src/application.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/application.cpp b/src/application.cpp
index df47a119..812081de 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -201,31 +201,26 @@ KUrl Application::guessUrlFromString(const QString &string)
QString urlStr = string.trimmed();
QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
+ // Might be a file.
+ if (QFile::exists(urlStr))
+ {
+ QFileInfo info(urlStr);
+ return KUrl::fromPath(info.absoluteFilePath());
+ }
+
// Check if it looks like a qualified URL. Try parsing it and see.
- bool hasSchema = test.exactMatch(urlStr);
-
- if (hasSchema)
+ if (test.exactMatch(urlStr))
{
- QUrl qurl(urlStr, QUrl::TolerantMode);
- KUrl url(qurl);
-
+ KUrl url(urlStr);
+
if (url.isValid())
{
return url;
}
}
-
- // Might be a file.
- if (QFile::exists(urlStr))
- {
- QFileInfo info(urlStr);
- return KUrl::fromPath(info.absoluteFilePath());
- }
-
- // Might be a shorturl - try to detect the schema.
- if (!hasSchema)
+ else // Might be a shorturl - try to detect the schema.
{
- int dotIndex = urlStr.indexOf(QLatin1Char('.'));
+ int dotIndex = urlStr.indexOf(QLatin1Char(':'));
if (dotIndex != -1)
{
@@ -240,17 +235,10 @@ KUrl Application::guessUrlFromString(const QString &string)
}
}
}
-
+
// Fall back to QUrl's own tolerant parser.
- QUrl qurl = QUrl(string, QUrl::TolerantMode);
- KUrl url(qurl);
+ KUrl url = KUrl(urlStr);
- // finally for cases where the user just types in a hostname add http
- if (qurl.scheme().isEmpty())
- {
- qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode);
- url = KUrl(qurl);
- }
return url;
}
@@ -305,7 +293,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
return;
}
- WebView *webView;
+ WebView *webView = 0;
switch(type)
{