🐛 Better fix for #4267

New helper OctoPrintClient.escapePath, does the equivalent
of x.split("/").map(e => escapeURIComponent(e)).join("/").

Used in the files API client.
This commit is contained in:
Gina Häußge committed 2021-10-29 17:10:04 +02:00
1 parent e71546d382
commit cbd463b0f9
2 files changed
+10 -4

No files matched your search

@@ -426,5 +426,11 @@
});
};
OctoPrintClient.escapePath = function (path) {
return _.map(path.split("/"), function (p) {
return encodeURIComponent(p);
}).join("/");
};
return OctoPrintClient;
});
+4 -4
View File
@@ -14,19 +14,19 @@
};
var resourceForLocation = function (location) {
return url + "/" + encodeURIComponent(location);
return url + "/" + OctoPrintClient.escapePath(location);
};
var downloadForLocation = function (location) {
return downloadUrl + "/" + encodeURIComponent(location);
return downloadUrl + "/" + OctoPrintClient.escapePath(location);
};
var downloadForEntry = function (location, filename) {
return downloadForLocation(location) + "/" + encodeURIComponent(filename);
return downloadForLocation(location) + "/" + OctoPrintClient.escapePath(filename);
};
var resourceForEntry = function (location, filename) {
return resourceForLocation(location) + "/" + encodeURIComponent(filename);
return resourceForLocation(location) + "/" + OctoPrintClient.escapePath(filename);
};
var preProcessList = function (response) {