From 3b0ee75d7fa9921f9acf2c8d112fca5ce64a6c26 Mon Sep 17 00:00:00 2001 From: TheSparta Date: Thu, 9 May 2024 15:22:10 +0100 Subject: [PATCH] Handle all bundles regarless of extension on BundleSerializer --- project/src/loaders/BundleLoader.ts | 3 +-- project/src/routers/dynamic/BundleDynamicRouter.ts | 2 +- project/src/routers/serializers/BundleSerializer.ts | 8 ++++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/project/src/loaders/BundleLoader.ts b/project/src/loaders/BundleLoader.ts index ad640fc2..d32cb035 100644 --- a/project/src/loaders/BundleLoader.ts +++ b/project/src/loaders/BundleLoader.ts @@ -56,8 +56,7 @@ export class BundleLoader public addBundles(modpath: string): void { - const bundleManifestArr - = this.jsonUtil.deserialize(this.vfs.readFile(`${modpath}bundles.json`)).manifest; + const bundleManifestArr = this.jsonUtil.deserialize(this.vfs.readFile(`${modpath}bundles.json`)).manifest; for (const bundleManifest of bundleManifestArr) { diff --git a/project/src/routers/dynamic/BundleDynamicRouter.ts b/project/src/routers/dynamic/BundleDynamicRouter.ts index ddfb6101..3dc757da 100644 --- a/project/src/routers/dynamic/BundleDynamicRouter.ts +++ b/project/src/routers/dynamic/BundleDynamicRouter.ts @@ -8,7 +8,7 @@ export class BundleDynamicRouter extends DynamicRouter constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) { super([ - new RouteAction(".bundle", (url: string, info: any, sessionID: string, output: string): any => + new RouteAction("/files/bundle", (url: string, info: any, sessionID: string, output: string): any => { return this.bundleCallbacks.getBundle(url, info, sessionID); }), diff --git a/project/src/routers/serializers/BundleSerializer.ts b/project/src/routers/serializers/BundleSerializer.ts index b6a5da13..7a16cab5 100644 --- a/project/src/routers/serializers/BundleSerializer.ts +++ b/project/src/routers/serializers/BundleSerializer.ts @@ -19,10 +19,14 @@ export class BundleSerializer extends Serializer public override serialize(sessionID: string, req: IncomingMessage, resp: ServerResponse, body: any): void { - this.logger.info(`[BUNDLE]: ${req.url}`); - const key = decodeURI(req.url.split("/bundle/")[1]); const bundle = this.bundleLoader.getBundle(key); + if (!bundle) + { + return; + } + + this.logger.info(`[BUNDLE]: ${req.url}`); this.httpFileUtil.sendFile(resp, `${bundle.modpath}/bundles/${bundle.filename}`); }