electron app: send filename in query filename= param, instead of as part of url path, more robust and should work on windows

This commit is contained in:
Ilya Kreymer
2020-06-09 18:58:17 -07:00
parent 1f226fe91a
commit 335c2bfd35
4 changed files with 11 additions and 5 deletions
+7 -1
View File
@@ -33,7 +33,13 @@ class Chooser extends LitElement
if (this.file) {
loadInfo.isFile = true;
// file.path only available in electron app
loadInfo.loadUrl = this.file.path ? __APP_FILE_SERVE_PREFIX__ + this.file.path : URL.createObjectURL(this.file);
if (this.file.path) {
const url = new URL(__APP_FILE_SERVE_PREFIX__);
url.searchParams.set("filename", this.file.path);
loadInfo.loadUrl = url.href;
} else {
loadInfo.loadUrl = URL.createObjectURL(this.file);
}
loadInfo.noCache = this.file.path !== undefined;
loadInfo.name = this.fileDisplayName;
}