summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r--src/corelib/io/qurl.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 51631ff..8e3f111 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -4755,11 +4755,10 @@ QString QUrl::host() const
if (!d) return QString();
if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();
- if (d->host.isEmpty() || d->host.at(0) != QLatin1Char('['))
- return d->canonicalHost();
- QString tmp = d->host.mid(1);
- tmp.truncate(tmp.length() - 1);
- return tmp;
+ QString result = d->canonicalHost();
+ if (result.startsWith(QLatin1Char('[')))
+ return result.mid(1, result.length() - 2);
+ return result;
}
/*!