[ui] Unescape csi/ in plugin GET requests (#23625)

* Unescape csi/ in plugin GET requests

* CSI de-prefixing no longer necessary in mirage mocked endpoint
This commit is contained in:
Phil Renaud
2024-07-26 13:19:42 -04:00
committed by GitHub
parent d5ca07a247
commit 08eab0045a
3 changed files with 12 additions and 7 deletions

3
.changelog/23625.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed storage/plugin 404s by unescaping a slash character in the request URL
```

View File

@@ -11,4 +11,11 @@ export default class PluginAdapter extends Watchable {
queryParamsToAttrs = {
type: 'type',
};
// Over in serializers/plugin.js, we prepend csi/ as part of the hash ID for request resolution reasons.
// However, this is not part of the actual ID stored in the database and we should treat it like a regular, unescaped
// path segment.
urlForFindRecord() {
let url = super.urlForFindRecord(...arguments);
return url.replace('csi%2F', 'csi/');
}
}

View File

@@ -673,13 +673,8 @@ export default function () {
return this.serialize(csiPlugins.all());
});
this.get('/plugin/:id', function ({ csiPlugins }, { params }) {
if (!params.id.startsWith('csi/')) {
return new Response(404, {}, null);
}
const id = params.id.replace(/^csi\//, '');
const volume = csiPlugins.find(id);
this.get('/plugin/csi/:id', function ({ csiPlugins }, { params }) {
const volume = csiPlugins.find(params.id);
if (!volume) {
return new Response(404, {}, null);