Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/urlutil_p.h
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 60 | { | |||
---|---|---|---|---|---|
61 | const QUrl adjustedLastUrl = lastUrl.adjusted(QUrl::StripTrailingSlash); | 61 | const QUrl adjustedLastUrl = lastUrl.adjusted(QUrl::StripTrailingSlash); | ||
62 | const QUrl adjustedCurrentUrl = currentUrl.adjusted(QUrl::StripTrailingSlash); | 62 | const QUrl adjustedCurrentUrl = currentUrl.adjusted(QUrl::StripTrailingSlash); | ||
63 | if (!adjustedCurrentUrl.isParentOf(adjustedLastUrl)) { | 63 | if (!adjustedCurrentUrl.isParentOf(adjustedLastUrl)) { | ||
64 | return QUrl(); | 64 | return QUrl(); | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | const QString childPath = adjustedLastUrl.path(); | 67 | const QString childPath = adjustedLastUrl.path(); | ||
68 | const QString parentPath = adjustedCurrentUrl.path(); | 68 | const QString parentPath = adjustedCurrentUrl.path(); | ||
69 | // if the parent path is root "/" | ||||
dfaure: s/S/s/ twice
You could also just use adjustedCurrentUrl.path(QUrl::StripTrailingSlash), no? | |||||
It is already done (it's a pity that this can't be seen creating the patch using the web): const QUrl adjustedLastUrl = lastUrl.adjusted(QUrl::StripTrailingSlash); const QUrl adjustedCurrentUrl = currentUrl.adjusted(QUrl::StripTrailingSlash); but in the case of the new test, the values are: jtamate: It is already done (it's a pity that this can't be seen creating the patch using the web)… | |||||
70 | // one char more is a valid path, otherwise "/" and another char are needed. | ||||
71 | const int minIndex = (parentPath == QLatin1String("/")) ? 1 : 2; | ||||
69 | 72 | | |||
70 | // e.g. this would just be ok: | 73 | // e.g. this would just be ok: | ||
74 | // childPath = /a len=2 | ||||
75 | // parentPath = / len=1 | ||||
71 | // childPath = /home/a len=7 | 76 | // childPath = /home/a len=7 | ||
72 | // parentPath = /home len=5 | 77 | // parentPath = /home len=5 | ||
73 | Q_ASSERT(childPath.length() >= (parentPath.length() + 2)); | | |||
74 | 78 | | |||
75 | const int idx2 = childPath.indexOf(QLatin1Char('/'), parentPath.length() + 2); | 79 | if (childPath.length() < (parentPath.length() + minIndex) ) { | ||
80 | return QUrl(); | ||||
81 | } | ||||
82 | | ||||
83 | const int idx2 = childPath.indexOf(QLatin1Char('/'), parentPath.length() + minIndex); | ||||
76 | // parentPath = /home | 84 | // parentPath = /home | ||
77 | // childPath = /home/a | 85 | // childPath = /home/a | ||
78 | // idx = -1 | 86 | // idx = -1 | ||
79 | // => len2 = 7 | 87 | // => len2 = 7 | ||
80 | // | 88 | // | ||
81 | // childPath = /homa/a/b | 89 | // childPath = /homa/a/b | ||
82 | // idx = 7 | 90 | // idx = 7 | ||
83 | // => len2 = 7 | 91 | // => len2 = 7 | ||
Show All 12 Lines |
s/S/s/ twice
You could also just use adjustedCurrentUrl.path(QUrl::StripTrailingSlash), no?
Then you wouldn't have to deal with the fact that the path might end with a slash
(and it would also cover the case where it ends with two or more consecutive slashes....)