Improve folder path construction logic to handle root and parent paths correctly
This commit is contained in:
@@ -119,9 +119,18 @@ class FileService {
|
|||||||
String parentPath,
|
String parentPath,
|
||||||
String folderName,
|
String folderName,
|
||||||
) async {
|
) async {
|
||||||
// Normalize parent path and construct new folder path
|
// Construct proper path: /parent/folder or /folder for root
|
||||||
final normalizedParent = parentPath == '/' ? '' : parentPath;
|
String path;
|
||||||
final path = '$normalizedParent/$folderName';
|
if (parentPath == '/') {
|
||||||
|
path = '/$folderName';
|
||||||
|
} else {
|
||||||
|
// Ensure parentPath doesn't end with / before appending
|
||||||
|
final cleanParent = parentPath.endsWith('/')
|
||||||
|
? parentPath.substring(0, parentPath.length - 1)
|
||||||
|
: parentPath;
|
||||||
|
path = '$cleanParent/$folderName';
|
||||||
|
}
|
||||||
|
|
||||||
final data = {
|
final data = {
|
||||||
'name': folderName,
|
'name': folderName,
|
||||||
'path': path,
|
'path': path,
|
||||||
|
|||||||
Reference in New Issue
Block a user