fix(core): Allow serving icons for custom nodes with npm scoped names (#5626)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-03-06 13:36:47 +01:00 committed by GitHub
parent 96142d78de
commit 45ccdd3bb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1293,8 +1293,9 @@ class Server extends AbstractServer {
},
};
this.app.use('/icons/:packageName/*/*.(svg|png)', async (req, res) => {
const { packageName } = req.params;
const serveIcons: express.RequestHandler = async (req, res) => {
let { scope, packageName } = req.params;
if (scope) packageName = `@${scope}/${packageName}`;
const loader = this.loadNodesAndCredentials.loaders[packageName];
if (loader) {
const pathPrefix = `/icons/${packageName}/`;
@ -1309,7 +1310,10 @@ class Server extends AbstractServer {
}
res.sendStatus(404);
});
};
this.app.use('/icons/@:scope/:packageName/*/*.(svg|png)', serveIcons);
this.app.use('/icons/:packageName/*/*.(svg|png)', serveIcons);
this.app.use(
'/',