File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,11 @@ export const jsonResponse = (value: JsonSerializable): ToHttpResponse => ({
5353/**
5454 * An HTML response with the content-type header set to text/html.
5555 */
56- export const htmlResponse = ( html : string ) : ToHttpResponse => ( {
56+ export const htmlResponse = ( html : string , charset = "utf-8" ) : ToHttpResponse => ( {
5757 [ TO_HTTP_RESPONSE ] : ( ) : HttpResponse => {
58- return HttpResponse . builder ( ) . header ( "content-type" , "text/html" ) . body ( html ) ;
58+ return HttpResponse . builder ( )
59+ . header ( "content-type" , `text/html; charset=${ charset } ` )
60+ . body ( html ) ;
5961 } ,
6062} ) ;
6163
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ describe("http:common", () => {
3737 const html = "<h1>Hello</h1>" ;
3838 const res = htmlResponse ( html ) [ TO_HTTP_RESPONSE ] ( ) ;
3939 assert . equal ( res . status . code , 200 ) ;
40- assert . equal ( res . headers . get ( "content-type" ) ?. value , "text/html" ) ;
40+ assert . equal ( res . headers . get ( "content-type" ) ?. value , "text/html; charset=utf-8 " ) ;
4141
4242 const body = await consumers . text ( res . body . readable ) ;
4343 assert . equal ( body , html ) ;
You can’t perform that action at this time.
0 commit comments