add proper undefined checks
This commit is contained in:
parent
d383cebe78
commit
4dc1f6d7c8
@ -38,7 +38,9 @@ export default class FileResponseFactory extends ResponseFactory {
|
|||||||
if ( content.headers && content.body && length ) {
|
if ( content.headers && content.body && length ) {
|
||||||
request.response.body = content.body
|
request.response.body = content.body
|
||||||
request.response.headers.set('Content-Length', length)
|
request.response.headers.set('Content-Length', length)
|
||||||
request.response.headers.set('Content-Type', path.content_type)
|
|
||||||
|
if ( path.content_type )
|
||||||
|
request.response.headers.set('Content-Type', path.content_type)
|
||||||
} else {
|
} else {
|
||||||
this.logger.debug(`Tried to serve file that does not exist: ${path}`)
|
this.logger.debug(`Tried to serve file that does not exist: ${path}`)
|
||||||
request.response.status = HTTPStatus.NOT_FOUND
|
request.response.status = HTTPStatus.NOT_FOUND
|
||||||
|
@ -102,6 +102,8 @@ export class UniversalPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get charset() {
|
get charset() {
|
||||||
return Mime.charset(this.mime_type)
|
if ( this.mime_type ) {
|
||||||
|
return Mime.charset(this.mime_type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user