X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fdingus.js;h=79cee2c448e6d61e7d641b45072c532bc52b8237;hb=3254d4bd8914ab48cb12c5039c87e2beeca55f7a;hp=3ca710e463db4fe614f469ea227b09bbc41e8325;hpb=ad464818fe8f839bea962f57bcdca4fe26c92ce7;p=squeep-api-dingus diff --git a/lib/dingus.js b/lib/dingus.js index 3ca710e..79cee2c 100644 --- a/lib/dingus.js +++ b/lib/dingus.js @@ -565,18 +565,20 @@ class Dingus { break; } const suffix = Enum.EncodingTypeSuffix[encoding]; - if (suffix) { - const encodedFilePath = `${filePath}${suffix}`; - const [ encodedStat, encodedData ] = await this._readFileInfo(encodedFilePath); - if (encodedStat) { - ([ stat, data ] = [ encodedStat, encodedData ]); - ctx.selectedEncoding = encoding; - Dingus.addEncodingHeader(res, encoding); - res.setHeader(Enum.Header.Vary, Enum.Header.AcceptEncoding); - this.logger.debug(_scope, 'serving encoded version', { ctx, encodedFilePath }); - } - break; + if (!suffix) { + this.logger.error(_scope, 'supported encoding missing mapped suffix', { ctx, encoding }); + continue; + } + const encodedFilePath = `${filePath}${suffix}`; + const [ encodedStat, encodedData ] = await this._readFileInfo(encodedFilePath); + if (encodedStat) { + ([ stat, data ] = [ encodedStat, encodedData ]); + ctx.selectedEncoding = encoding; + Dingus.addEncodingHeader(res, encoding); + res.setHeader(Enum.Header.Vary, Enum.Header.AcceptEncoding); + this.logger.debug(_scope, 'serving encoded version', { ctx, encodedFilePath }); } + break; } const lastModifiedDate = new Date(stat.mtimeMs);