Skip to content

Commit c8552ce

Browse files
Modified the NativeFileData path function for WebFileData to return the webkitRelativePath property if it exists, or just the file name if it does not exist. (#5015)
1 parent 0dd2cb4 commit c8552ce

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/web/src/files.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ impl NativeFileData for WebFileData {
135135
}
136136

137137
fn path(&self) -> std::path::PathBuf {
138+
let key = JsValue::from_str("webkitRelativePath");
139+
140+
if let Ok(value) = js_sys::Reflect::get(&self.file, &key) {
141+
if let Some(path_str) = value.as_string() {
142+
if !path_str.is_empty() {
143+
return std::path::PathBuf::from(path_str);
144+
}
145+
}
146+
}
147+
138148
std::path::PathBuf::from(self.file.name())
139149
}
140150

0 commit comments

Comments
 (0)