mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 14:56:20 +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
|
/// Return the path of this file with the DAV part stripped
|
||||||
|
///
|
||||||
|
/// WebDAV file path: remote.php/dav/files/{username}/{strippedPath}
|
||||||
String get strippedPath {
|
String get strippedPath {
|
||||||
// WebDAV path: remote.php/dav/files/{username}/{path}
|
|
||||||
if (path.contains("remote.php/dav/files")) {
|
if (path.contains("remote.php/dav/files")) {
|
||||||
return path
|
final position = path.indexOf("/", "remote.php/dav/files/".length) + 1;
|
||||||
.substring(path.indexOf("/", "remote.php/dav/files/".length) + 1);
|
if (position == 0) {
|
||||||
|
// root dir path
|
||||||
|
return ".";
|
||||||
|
} else {
|
||||||
|
return path.substring(position);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -749,9 +749,16 @@ void main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("strippedPath", () {
|
group("strippedPath", () {
|
||||||
final file = File(path: "/remote.php/dav/files/admin/test.jpg");
|
test("file", () {
|
||||||
expect(file.strippedPath, "admin/test.jpg");
|
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