mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +01:00
Fix root dir path is not stripped correctly
This commit is contained in:
parent
3c70d6f5e2
commit
72e6e7a9ec
2 changed files with 19 additions and 6 deletions
|
@ -302,11 +302,17 @@ class File with EquatableMixin {
|
|||
}
|
||||
|
||||
/// Return the path of this file with the DAV part stripped
|
||||
///
|
||||
/// WebDAV file path: remote.php/dav/files/{username}/{strippedPath}
|
||||
String get strippedPath {
|
||||
// WebDAV path: remote.php/dav/files/{username}/{path}
|
||||
if (path.contains("remote.php/dav/files")) {
|
||||
return path
|
||||
.substring(path.indexOf("/", "remote.php/dav/files/".length) + 1);
|
||||
final position = path.indexOf("/", "remote.php/dav/files/".length) + 1;
|
||||
if (position == 0) {
|
||||
// root dir path
|
||||
return ".";
|
||||
} else {
|
||||
return path.substring(position);
|
||||
}
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -749,9 +749,16 @@ void main() {
|
|||
});
|
||||
});
|
||||
|
||||
test("strippedPath", () {
|
||||
final file = File(path: "/remote.php/dav/files/admin/test.jpg");
|
||||
expect(file.strippedPath, "admin/test.jpg");
|
||||
group("strippedPath", () {
|
||||
test("file", () {
|
||||
final file = File(path: "/remote.php/dav/files/admin/test.jpg");
|
||||
expect(file.strippedPath, "admin/test.jpg");
|
||||
});
|
||||
|
||||
test("root dir", () {
|
||||
final file = File(path: "/remote.php/dav/files/admin");
|
||||
expect(file.strippedPath, ".");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue