mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kdecore: strip the trailing slash when passing the URL path to kPathDirectory() from KUrl::upUrl()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c4d7fcfaa8
commit
f90c94dae7
2 changed files with 7 additions and 2 deletions
|
@ -64,6 +64,7 @@ static QString kPathDirectory(const QString &path)
|
|||
if (lastslash == 0) {
|
||||
return QString(QLatin1Char('/'));
|
||||
}
|
||||
Q_ASSERT(!path.endsWith(QLatin1Char('/')));
|
||||
QString result = path.left(lastslash);
|
||||
result.append(QLatin1Char('/'));
|
||||
return result;
|
||||
|
@ -614,7 +615,8 @@ KUrl KUrl::upUrl() const
|
|||
return result;
|
||||
}
|
||||
|
||||
if (QDir::cleanPath(urlpath).count(QLatin1Char('/')) <= 1) {
|
||||
const QString cleanurlpath = QDir::cleanPath(urlpath);
|
||||
if (cleanurlpath.count(QLatin1Char('/')) <= 1) {
|
||||
// something like /home
|
||||
KUrl result(*this);
|
||||
result.setPath(QLatin1String("/"));
|
||||
|
@ -627,7 +629,7 @@ KUrl KUrl::upUrl() const
|
|||
QString newpath;
|
||||
if (urlpath.endsWith(QLatin1Char('/'))) {
|
||||
// assuming it is directory
|
||||
newpath = kPathDirectory(urlpath);
|
||||
newpath = kPathDirectory(cleanurlpath);
|
||||
} else {
|
||||
// the only way to be sure is to stat() then
|
||||
KDE_struct_stat statbuff;
|
||||
|
|
|
@ -48,6 +48,9 @@ void KUrlTest::testUpUrl_data()
|
|||
QTest::newRow("local file 3")
|
||||
<< KUrl("kde//foo?bar=baz#foobar")
|
||||
<< KUrl("../kde/");
|
||||
QTest::newRow("local file 4 - trailing slash")
|
||||
<< KUrl("/home/foo/bar/")
|
||||
<< KUrl("/home/foo/");
|
||||
QTest::newRow("ftp url")
|
||||
<< KUrl("ftp://ftp.kde.org/foo?bar=baz#foobar")
|
||||
<< KUrl("ftp://ftp.kde.org/");
|
||||
|
|
Loading…
Add table
Reference in a new issue