Fix QUrl::StripTrailingSlash for the case of no path at all.
authorDavid Faure <faure@kde.org>
Tue, 8 May 2012 11:17:26 +0000 (13:17 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 9 May 2012 10:07:33 +0000 (12:07 +0200)
Change-Id: I1fd0fe4b9b67996732c85c1792415e371e865595
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/io/qurl.cpp
tests/auto/corelib/io/qurl/tst_qurl.cpp

index 649b3a0..f975fb4 100644 (file)
@@ -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);
     }
 
index 92717e9..46d491b 100644 (file)
@@ -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()