Fix cannot ready property csp of undefined

This commit is contained in:
Sébastien Chopin 2018-01-10 17:31:27 +01:00 committed by GitHub
parent 6e9be715b2
commit 9a3bfdc998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,9 +34,6 @@ Options.from = function (_options) {
if (typeof options.extensions === 'string') { if (typeof options.extensions === 'string') {
options.extensions = [ options.extensions ] options.extensions = [ options.extensions ]
} }
if (options.render.csp === true) {
options.render.csp = { hashAlgorithm: 'sha256' }
}
const hasValue = v => typeof v === 'string' && v const hasValue = v => typeof v === 'string' && v
options.rootDir = hasValue(options.rootDir) ? options.rootDir : process.cwd() options.rootDir = hasValue(options.rootDir) ? options.rootDir : process.cwd()
@ -91,6 +88,11 @@ Options.from = function (_options) {
options.loadingIndicator = { name: options.loadingIndicator } options.loadingIndicator = { name: options.loadingIndicator }
} }
// Apply default hash to CSP option
if (options.render.csp === true) {
options.render.csp = { hashAlgorithm: 'sha256' }
}
// Apply defaults to loadingIndicator // Apply defaults to loadingIndicator
options.loadingIndicator = Object.assign({ options.loadingIndicator = Object.assign({
name: 'pulse', name: 'pulse',