diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp
index a7d3bbad8193b979fdfc51075241eb4de8bdcbc6..76b1965cba6d4d1888c37b980c97627d42044c14 100644
--- a/src/shared/proparser/profileevaluator.cpp
+++ b/src/shared/proparser/profileevaluator.cpp
@@ -2220,7 +2220,7 @@ QStringList ProFileEvaluator::Private::evaluateExpandFunction(const QString &fun
                 }
                 int slash = r.lastIndexOf(QDir::separator());
                 if (slash != -1) {
-                    dirs.append(r.left(slash));
+                    dirs.append(r.left(slash+1));
                     r = r.mid(slash+1);
                 } else {
                     dirs.append(QString());
@@ -2230,15 +2230,13 @@ QStringList ProFileEvaluator::Private::evaluateExpandFunction(const QString &fun
                 for (int d = 0; d < dirs.count(); d++) {
                     QString dir = dirs[d];
                     QDir qdir(pfx + dir);
-                    if (!dir.isEmpty() && !dir.endsWith(QDir::separator()))
-                        dir += QDir::separator();
                     for (int i = 0; i < (int)qdir.count(); ++i) {
                         if (qdir[i] == statics.strDot || qdir[i] == statics.strDotDot)
                             continue;
                         QString fname = dir + qdir[i];
                         if (IoUtils::fileType(pfx + fname) == IoUtils::FileIsDir) {
                             if (recursive)
-                                dirs.append(fname);
+                                dirs.append(fname + QDir::separator());
                         }
                         if (regex.exactMatch(qdir[i]))
                             ret += fname;