mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: append trailing slash from kPathDirectory() function
while it does not matter for comparison, for KUrl::setFileName() to produce correct results it has to be there after KUrl::upUrl() Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
471df42df0
commit
a051b1b284
2 changed files with 11 additions and 2 deletions
|
@ -64,7 +64,9 @@ static QString kPathDirectory(const QString &path)
|
|||
if (lastslash == 0) {
|
||||
return QString(QLatin1Char('/'));
|
||||
}
|
||||
return path.left(lastslash);
|
||||
QString result = path.left(lastslash);
|
||||
result.append(QLatin1Char('/'));
|
||||
return result;
|
||||
}
|
||||
|
||||
static QByteArray kUriListData(const KUrl::List &urls)
|
||||
|
@ -614,7 +616,8 @@ KUrl KUrl::upUrl() const
|
|||
if (KDE_stat(urlpathencoded, &statbuff) == 0 && S_ISDIR(statbuff.st_mode)) {
|
||||
newpath = kPathDirectory(urlpath);
|
||||
} else {
|
||||
newpath = kPathDirectory(kPathDirectory(urlpath));
|
||||
newpath = kPathDirectory(urlpath);
|
||||
newpath = kPathDirectory(newpath.mid(0, newpath.size() - 1));
|
||||
}
|
||||
}
|
||||
KUrl result(*this);
|
||||
|
|
|
@ -61,6 +61,12 @@ void KUrlTest::testUpUrl()
|
|||
KUrl newUrl = url.upUrl();
|
||||
// qDebug() << Q_FUNC_INFO << newUrl << url2;
|
||||
QCOMPARE(newUrl, url2);
|
||||
const QString newPath = newUrl.path();
|
||||
if (newPath.isEmpty()) {
|
||||
// empty/null URL, if the slash is there it will be root path ("/")
|
||||
return;
|
||||
}
|
||||
QCOMPARE(newPath[newPath.size() - 1], QChar::fromLatin1('/'));
|
||||
}
|
||||
|
||||
void KUrlTest::testHash_data()
|
||||
|
|
Loading…
Add table
Reference in a new issue