Fixed "load workflow " to provide human-readable image file name.

This commit is contained in:
Christian Bastian
2024-09-23 18:41:37 -04:00
parent 75f922bea2
commit e01afe01b6

View File

@@ -104,11 +104,10 @@ const IS_FIREFOX = navigator.userAgent.indexOf('Firefox') > -1;
* @param {string} url
*/
async function loadWorkflow(url) {
const fileNameIndex = Math.max(url.lastIndexOf('/'), url.lastIndexOf('\\')) + 1;
const fileName = url.substring(fileNameIndex);
const fileName = SearchPath.filename(decodeURIComponent(url));
const response = await fetch(url);
const data = await response.blob();
const file = new File([data], fileName, { type: data.type });
const file = new File([data], fileName, { type: data.type });
app.handleFile(file);
}
@@ -261,6 +260,19 @@ class SearchPath {
const i2 = path.indexOf(searchSeparator, i1 + 1);
return path.slice(i2 + 1).replaceAll(searchSeparator, systemSeparator);
}
/**
* @param {string} s search path or url
* @returns {string}
*/
static filename(s) {
let name = SearchPath.split(s)[1];
const queryIndex = name.indexOf('?');
if (queryIndex > -1) {
return name.substring(0, queryIndex);
}
return name;
}
}
/**