Skip to content

Commit df5e92b

Browse files
committed
fix(utils): avoid setting falsy type
1 parent d8bb186 commit df5e92b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ export const MIMES = {
66
json: 'application/json'
77
}
88

9-
export function send (res: ServerResponse, data: string, type: string) {
10-
defaultContentType(res, type)
9+
export function send (res: ServerResponse, data: any, type?: string) {
10+
if (type) {
11+
defaultContentType(res, type)
12+
}
1113
res.end(data)
1214
}
1315

14-
export function defaultContentType (res: ServerResponse, type: string) {
15-
if (!res.getHeader('Content-Type')) {
16+
export function defaultContentType (res: ServerResponse, type?: string) {
17+
if (type && !res.getHeader('Content-Type')) {
1618
res.setHeader('Content-Type', type)
1719
}
1820
}

0 commit comments

Comments
 (0)