Remove path from fsentry metadata, make vfs and webdav work again with fixes

This commit is contained in:
timurgordon
2025-03-12 02:16:40 +01:00
parent f1991d89b3
commit ff430c2e4d
48 changed files with 1424 additions and 1350 deletions

View File

@@ -116,11 +116,20 @@ pub fn name_fix_dot_notation_to_snake_case(name string) string {
return name.replace('.', '_')
}
// remove underscores and extension
pub fn name_fix_no_underscore_no_ext(name_ string) string {
return name_fix_keepext(name_).all_before_last('.').replace('_', '')
// normalize a file path while preserving path structure
pub fn path_fix(path_ string) string {
if path_.len == 0 {
return ''
}
return "${path_.trim('/')}"
}
// normalize a file path while preserving path structure
pub fn path_fix_absolute(path string) string {
return "/${path_fix(path)}"
}
// remove underscores and extension
pub fn name_fix_no_ext(name_ string) string {
return name_fix_keepext(name_).all_before_last('.').trim_right('_')

View File

@@ -6,3 +6,33 @@ fn test_main() {
assert name_fix_keepext('\$sds_?_!"`{_ 4F') == 'sds_4f'
assert name_fix_keepext('\$sds_?_!"`{_ 4F.jpg') == 'sds_4f.jpg'
}
fn test_path_fix() {
// Test empty path
assert path_fix('') == ''
// Test absolute paths
assert path_fix('/home/user') == '/home/user'
assert path_fix('/home/USER') == '/home/user'
assert path_fix('/home/user/Documents') == '/home/user/documents'
// Test relative paths
assert path_fix('home/user') == 'home/user'
assert path_fix('./home/user') == './home/user'
assert path_fix('../home/user') == '../home/user'
// Test paths with special characters
assert path_fix('/home/user/My Documents') == '/home/user/my_documents'
assert path_fix('/home/user/file-name.txt') == '/home/user/file_name.txt'
assert path_fix('/home/user/file name with spaces.txt') == '/home/user/file_name_with_spaces.txt'
// Test paths with multiple special characters
assert path_fix('/home/user/!@#$%^&*()_+.txt') == '/home/user/'
// Test paths with multiple components and extensions
assert path_fix('/home/user/Documents/report.pdf') == '/home/user/documents/report.pdf'
assert path_fix('/home/user/Documents/report.PDF') == '/home/user/documents/report.pdf'
// Test paths with multiple slashes
assert path_fix('/home//user///documents') == '/home/user/documents'
}