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 folderName,
|
||||
) async {
|
||||
// Normalize parent path and construct new folder path
|
||||
final normalizedParent = parentPath == '/' ? '' : parentPath;
|
||||
final path = '$normalizedParent/$folderName';
|
||||
// Construct proper path: /parent/folder or /folder for root
|
||||
String path;
|
||||
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 = {
|
||||
'name': folderName,
|
||||
'path': path,
|
||||
|
||||
Reference in New Issue
Block a user