Skip to content

Commit

Permalink
fix(api): set charset along with Content-Type response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Oct 22, 2020
1 parent 6545898 commit 80e9433
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function build({paths, features, featuresRequested, userAgent, cont
const banner = `\
/**
* ${featuresRequestedText}
*
* ${polyfillsAppliedText}
* @preserve
*/
Expand Down
4 changes: 2 additions & 2 deletions src/controller/polyfill/polyfill-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class PolyfillController extends Controller implements IPolyfillControlle

// Return an OK
return {
contentType: "application/javascript",
contentType: "application/javascript; charset=utf-8",
statusCode: request.http2 ? constants.HTTP_STATUS_OK : OK,
body: buffer,
cacheControl: "public,max-age=31536000,immutable",
Expand All @@ -61,7 +61,7 @@ export class PolyfillController extends Controller implements IPolyfillControlle
const statusCode = request.http2 ? constants.HTTP_STATUS_INTERNAL_SERVER_ERROR : INTERNAL_SERVER_ERROR;

return {
contentType: "text/html",
contentType: "text/html; charset=utf-8",
statusCode,
body: generateErrorHtml(ex, statusCode)
};
Expand Down
15 changes: 6 additions & 9 deletions test/server/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,12 @@ test("Is able to generate a bundle of every available polyfill", async t => {
const features = Object.entries(constant.polyfill)
.filter(([, value]) => !("polyfills" in value))
.map(([key, value]) => {
switch (key) {
case "zone":
return `${key}|${Object.keys(((value as unknown) as PolyfillDictNormalizedEntry).meta!).join("|")}|force`;
case "intl.core":
case "intl.list-format":
case "intl.relative-time-format":
return `${key}|locale=en~da|force`;
default:
return `${key}|force`;
if (key === "zone") {
return `${key}|${Object.keys(((value as unknown) as PolyfillDictNormalizedEntry).meta!).join("|")}|force`;
} else if (key.startsWith("intl.")) {
return `${key}|locale=en~da|force`;
} else {
return `${key}|force`;
}
});

Expand Down

0 comments on commit 80e9433

Please sign in to comment.