diff options
-rw-r--r-- | src/corelib/io/qurl.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 649b3a009c..f975fb4e43 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2159,7 +2159,7 @@ QString QUrl::toString(FormattingOptions options) const d->appendPath(url, options, QUrlPrivate::FullUrl); // check if we need to remove trailing slashes - if ((options & StripTrailingSlash) && d->path != QLatin1String("/") && url.endsWith(QLatin1Char('/'))) + if ((options & StripTrailingSlash) && !d->path.isEmpty() && d->path != QLatin1String("/") && url.endsWith(QLatin1Char('/'))) url.chop(1); } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 92717e96f9..46d491ba79 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2257,6 +2257,7 @@ void tst_QUrl::stripTrailingSlash_data() QTest::newRow("file slash") << "file:///dir/" << "file:///dir"; QTest::newRow("file no slash") << "file:///dir/" << "file:///dir"; QTest::newRow("file root") << "file:///" << "file:///"; + QTest::newRow("no path") << "remote://" << "remote://"; } void tst_QUrl::stripTrailingSlash() |