lambder 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -149,7 +149,7 @@ export default class LambderResponseBuilder {
|
|
|
149
149
|
return this.raw({
|
|
150
150
|
statusCode: 200,
|
|
151
151
|
isBase64Encoded: true,
|
|
152
|
-
multiValueHeaders: { "Content-Type": [mimeType || "
|
|
152
|
+
multiValueHeaders: { "Content-Type": [mimeType || "application/octet-stream"], ...convertToMultiHeader(headers) },
|
|
153
153
|
body: fileBase64,
|
|
154
154
|
});
|
|
155
155
|
}
|
|
@@ -173,7 +173,7 @@ export default class LambderResponseBuilder {
|
|
|
173
173
|
const bodyBuffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
|
|
174
174
|
const bodyBase64 = bodyBuffer.toString("base64");
|
|
175
175
|
console.log("bodyBase64.length", bodyBase64.length);
|
|
176
|
-
return this.fileBase64(bodyBase64, mimeType || "", headers);
|
|
176
|
+
return this.fileBase64(bodyBase64, mimeType || "application/octet-stream", headers);
|
|
177
177
|
}
|
|
178
178
|
;
|
|
179
179
|
async ejsTemplate(template, pageData, headers) {
|
package/package.json
CHANGED
|
@@ -202,7 +202,7 @@ export default class LambderResponseBuilder<TResponse = any> {
|
|
|
202
202
|
return this.raw({
|
|
203
203
|
statusCode: 200,
|
|
204
204
|
isBase64Encoded: true,
|
|
205
|
-
multiValueHeaders: { "Content-Type": [mimeType || "
|
|
205
|
+
multiValueHeaders: { "Content-Type": [mimeType || "application/octet-stream"], ...convertToMultiHeader(headers) },
|
|
206
206
|
body: fileBase64,
|
|
207
207
|
});
|
|
208
208
|
};
|
|
@@ -230,7 +230,7 @@ export default class LambderResponseBuilder<TResponse = any> {
|
|
|
230
230
|
const bodyBuffer: Buffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
|
|
231
231
|
const bodyBase64 = bodyBuffer.toString("base64");
|
|
232
232
|
console.log("bodyBase64.length",bodyBase64.length);
|
|
233
|
-
return this.fileBase64(bodyBase64, mimeType || "", headers);
|
|
233
|
+
return this.fileBase64(bodyBase64, mimeType || "application/octet-stream", headers);
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
async ejsTemplate(
|
|
@@ -167,4 +167,28 @@ describe('File Serving with Fallback', () => {
|
|
|
167
167
|
const fallbackBody = Buffer.from(fallbackResult.body || '', 'base64').toString();
|
|
168
168
|
expect(fallbackBody).toContain('<h1>Test HTML</h1>');
|
|
169
169
|
});
|
|
170
|
+
|
|
171
|
+
it('should serve CSS file with correct text/css MIME type', async () => {
|
|
172
|
+
const lambder = new Lambder({
|
|
173
|
+
publicPath: path.resolve('./tests/fixtures/public'),
|
|
174
|
+
apiPath: '/api'
|
|
175
|
+
})
|
|
176
|
+
.addRoute('/(.*)', (ctx, res) => {
|
|
177
|
+
return res.file(ctx.path);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const handler = lambder.getHandler();
|
|
181
|
+
const event = createMockEvent('/main.css');
|
|
182
|
+
const result = await handler(event, createMockContext());
|
|
183
|
+
|
|
184
|
+
expect(result.statusCode).toBe(200);
|
|
185
|
+
|
|
186
|
+
// Verify Content-Type header is exactly text/css
|
|
187
|
+
expect(result.multiValueHeaders?.['Content-Type']).toBeDefined();
|
|
188
|
+
expect(result.multiValueHeaders?.['Content-Type']?.[0]).toBe('text/css');
|
|
189
|
+
|
|
190
|
+
// Verify body contains CSS content
|
|
191
|
+
const body = Buffer.from(result.body || '', 'base64').toString();
|
|
192
|
+
expect(body).toContain('body { margin: 0; }');
|
|
193
|
+
});
|
|
170
194
|
});
|