mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Merge remote-tracking branch 'upstream/dev' into next
This commit is contained in:
commit
fc5502cd8d
@ -8,7 +8,7 @@ const port = process.env.PORT || 3000
|
||||
|
||||
// Import and set Nuxt.js options
|
||||
const config = require('./nuxt.config.js')
|
||||
config.dev = !(process.env.NODE_ENV === 'production')
|
||||
config.dev = process.env.NODE_ENV !== 'production'
|
||||
|
||||
const nuxt = new Nuxt(config)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
import { storiesOf } from '@storybook/vue'
|
||||
import MyButton from '~/components/Button.vue'
|
||||
import Centered from '@storybook/addon-centered'
|
||||
import MyButton from '~/components/Button.vue'
|
||||
|
||||
storiesOf('Button', module)
|
||||
.addDecorator(Centered)
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
import Vuex from 'vuex'
|
||||
import { storiesOf } from '@storybook/vue'
|
||||
import { action } from '@storybook/addon-actions'
|
||||
@ -226,5 +225,3 @@ storiesOf('Features/ Addon Knobs', module)
|
||||
`
|
||||
}
|
||||
})
|
||||
|
||||
/* eslint-enable react/react-in-jsx-scope */
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { storiesOf } from '@storybook/vue'
|
||||
|
||||
import VuetifyLogo from '~/components/VuetifyLogo.vue'
|
||||
|
||||
import Centered from '@storybook/addon-centered'
|
||||
import VuetifyLogo from '~/components/VuetifyLogo.vue'
|
||||
|
||||
storiesOf('Vuetify/Logo', module)
|
||||
.addDecorator(Centered)
|
||||
|
@ -7,9 +7,10 @@ const config: NuxtConfiguration = {
|
||||
manualInject: true
|
||||
},
|
||||
css: {
|
||||
modules: true,
|
||||
importLoaders: 1,
|
||||
localIdentName: '[local]_[hash:base64:5]'
|
||||
modules: {
|
||||
localIdentName: '[local]_[hash:base64:5]'
|
||||
},
|
||||
importLoaders: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import Card from '~/components/Card.vue'
|
||||
import { namespace } from 'vuex-class'
|
||||
import Card from '~/components/Card.vue'
|
||||
|
||||
import * as people from '~/store/modules/people'
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DoughnutChart from '~/components/doughnut-chart'
|
||||
import axios from 'axios'
|
||||
import DoughnutChart from '~/components/doughnut-chart'
|
||||
|
||||
function getRandomColor() {
|
||||
const letters = '0123456789ABCDEF'
|
||||
|
@ -5,9 +5,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BarChart from '~/components/bar-chart'
|
||||
import axios from 'axios'
|
||||
import moment from 'moment'
|
||||
import BarChart from '~/components/bar-chart'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
@ -4,7 +4,7 @@ import glob from 'glob-all'
|
||||
|
||||
class TailwindExtractor {
|
||||
static extract(content) {
|
||||
return content.match(/[A-z0-9-:/]+/g) || []
|
||||
return content.match(/[A-Za-z0-9-:/]+/g) || []
|
||||
}
|
||||
}
|
||||
|
||||
|
34
package.json
34
package.json
@ -36,31 +36,31 @@
|
||||
"@nuxtjs/eslint-config": "^0.0.1",
|
||||
"@vue/server-test-utils": "^1.0.0-beta.29",
|
||||
"@vue/test-utils": "^1.0.0-beta.29",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-eslint": "^10.0.2",
|
||||
"babel-jest": "^24.8.0",
|
||||
"babel-plugin-dynamic-import-node": "^2.2.0",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.0",
|
||||
"cheerio": "^1.0.0-rc.3",
|
||||
"codecov": "^3.5.0",
|
||||
"consola": "^2.7.1",
|
||||
"consola": "^2.9.0",
|
||||
"cross-spawn": "^6.0.5",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint": "^6.0.1",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-multiplexer": "^1.0.4",
|
||||
"eslint-plugin-import": "^2.17.3",
|
||||
"eslint-plugin-jest": "^22.6.4",
|
||||
"eslint-plugin-import": "^2.18.0",
|
||||
"eslint-plugin-jest": "^22.7.1",
|
||||
"eslint-plugin-node": "^9.1.0",
|
||||
"eslint-plugin-promise": "^4.1.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^5.2.2",
|
||||
"eslint-plugin-vue": "^5.2.3",
|
||||
"esm": "^3.2.25",
|
||||
"execa": "^1.0.0",
|
||||
"execa": "^2.0.0",
|
||||
"express": "^4.17.1",
|
||||
"finalhandler": "^1.1.2",
|
||||
"fork-ts-checker-webpack-plugin": "^1.3.7",
|
||||
"fs-extra": "^8.0.1",
|
||||
"fs-extra": "^7.0.1",
|
||||
"get-port": "^5.0.0",
|
||||
"glob": "^7.1.4",
|
||||
"is-wsl": "^2.0.0",
|
||||
"is-wsl": "^2.1.0",
|
||||
"jest": "^24.8.0",
|
||||
"jest-junit": "^6.4.0",
|
||||
"jsdom": "^15.1.1",
|
||||
@ -68,24 +68,24 @@
|
||||
"lerna": "^3.15.0",
|
||||
"lodash": "^4.17.11",
|
||||
"node-fetch": "^2.6.0",
|
||||
"puppeteer-core": "^1.17.0",
|
||||
"puppeteer-core": "^1.18.0",
|
||||
"request": "^2.88.0",
|
||||
"request-promise-native": "^1.0.7",
|
||||
"rimraf": "^2.6.3",
|
||||
"rollup": "^1.15.5",
|
||||
"rollup": "^1.16.2",
|
||||
"rollup-plugin-alias": "^1.5.2",
|
||||
"rollup-plugin-babel": "^4.3.2",
|
||||
"rollup-plugin-babel": "^4.3.3",
|
||||
"rollup-plugin-commonjs": "^10.0.0",
|
||||
"rollup-plugin-json": "^4.0.0",
|
||||
"rollup-plugin-license": "^0.9.0",
|
||||
"rollup-plugin-node-resolve": "^5.0.2",
|
||||
"rollup-plugin-node-resolve": "^5.1.0",
|
||||
"rollup-plugin-replace": "^2.2.0",
|
||||
"sort-package-json": "^1.22.1",
|
||||
"ts-jest": "^24.0.2",
|
||||
"ts-node": "^8.2.0",
|
||||
"tslint": "^5.17.0",
|
||||
"ts-node": "^8.3.0",
|
||||
"tslint": "^5.18.0",
|
||||
"typescript": "^3.5.2",
|
||||
"vue-jest": "^4.0.0-beta.2",
|
||||
"vue-property-decorator": "^8.1.1"
|
||||
"vue-property-decorator": "^8.2.1"
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,14 @@
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"@nuxt/vue-app": "2.8.1",
|
||||
"chokidar": "^3.0.1",
|
||||
"consola": "^2.7.1",
|
||||
"fs-extra": "^8.0.1",
|
||||
"consola": "^2.9.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"glob": "^7.1.4",
|
||||
"hash-sum": "^1.0.2",
|
||||
"ignore": "^5.1.2",
|
||||
"lodash": "^4.17.11",
|
||||
"pify": "^4.0.1",
|
||||
"semver": "^6.1.1",
|
||||
"semver": "^6.1.2",
|
||||
"serialize-javascript": "^1.7.0",
|
||||
"upath": "^1.1.2"
|
||||
},
|
||||
|
@ -16,11 +16,11 @@
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"boxen": "^4.1.0",
|
||||
"chalk": "^2.4.2",
|
||||
"consola": "^2.7.1",
|
||||
"consola": "^2.9.0",
|
||||
"esm": "^3.2.25",
|
||||
"execa": "^1.0.0",
|
||||
"execa": "^2.0.0",
|
||||
"exit": "^0.1.2",
|
||||
"fs-extra": "^8.0.1",
|
||||
"fs-extra": "^7.0.1",
|
||||
"minimist": "^1.2.0",
|
||||
"opener": "1.5.1",
|
||||
"pretty-bytes": "^5.2.0",
|
||||
|
@ -33,7 +33,7 @@ export default async function run(_argv) {
|
||||
stdin: process.stdin
|
||||
})
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
if (error.exitCode === 2) {
|
||||
throw String(`Command not found: nuxt-${argv[0]}`)
|
||||
}
|
||||
throw String(`Failed to run command \`nuxt-${argv[0]}\`:\n${error}`)
|
||||
|
@ -48,7 +48,8 @@ describe('run', () => {
|
||||
test('throws error if external command not found', async () => {
|
||||
execa.mockImplementationOnce(() => {
|
||||
const e = new Error()
|
||||
e.code = 'ENOENT'
|
||||
e.exitCode = 2
|
||||
e.exitName = 'ENOENT'
|
||||
throw e
|
||||
})
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
"typings": "types/index.d.ts",
|
||||
"dependencies": {
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"consola": "^2.7.1",
|
||||
"consola": "^2.9.0",
|
||||
"std-env": "^2.2.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@ -41,7 +41,9 @@ export default () => ({
|
||||
},
|
||||
css: {},
|
||||
cssModules: {
|
||||
localIdentName: '[local]_[hash:base64:5]'
|
||||
modules: {
|
||||
localIdentName: '[local]_[hash:base64:5]'
|
||||
}
|
||||
},
|
||||
less: {},
|
||||
sass: {
|
||||
|
@ -220,6 +220,7 @@ export function getNuxtConfig(_options) {
|
||||
allowedSources: undefined,
|
||||
policies: undefined,
|
||||
addMeta: Boolean(options._generate),
|
||||
unsafeInlineCompatiblity: false,
|
||||
reportOnly: options.debug
|
||||
})
|
||||
}
|
||||
|
@ -65,7 +65,9 @@ Object {
|
||||
"sourceMap": false,
|
||||
},
|
||||
"cssModules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
"modules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
},
|
||||
"sourceMap": false,
|
||||
},
|
||||
"file": Object {},
|
||||
|
@ -50,7 +50,9 @@ Object {
|
||||
"loaders": Object {
|
||||
"css": Object {},
|
||||
"cssModules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
"modules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
},
|
||||
},
|
||||
"file": Object {},
|
||||
"fontUrl": Object {
|
||||
@ -390,7 +392,9 @@ Object {
|
||||
"loaders": Object {
|
||||
"css": Object {},
|
||||
"cssModules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
"modules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
},
|
||||
},
|
||||
"file": Object {},
|
||||
"fontUrl": Object {
|
||||
|
@ -92,6 +92,7 @@ describe('config: options', () => {
|
||||
expect(csp).toEqual({
|
||||
hashAlgorithm: 'sha256',
|
||||
addMeta: false,
|
||||
unsafeInlineCompatiblity: false,
|
||||
allowedSources: true,
|
||||
policies: undefined,
|
||||
reportOnly: false,
|
||||
|
@ -13,10 +13,10 @@
|
||||
"@nuxt/server": "2.8.1",
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"@nuxt/vue-renderer": "2.8.1",
|
||||
"consola": "^2.7.1",
|
||||
"consola": "^2.9.0",
|
||||
"debug": "^4.1.1",
|
||||
"esm": "^3.2.25",
|
||||
"fs-extra": "^8.0.1",
|
||||
"fs-extra": "^7.0.1",
|
||||
"hash-sum": "^1.0.2",
|
||||
"std-env": "^2.2.1"
|
||||
},
|
||||
|
@ -10,8 +10,8 @@
|
||||
"dependencies": {
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"chalk": "^2.4.2",
|
||||
"consola": "^2.7.1",
|
||||
"fs-extra": "^8.0.1",
|
||||
"consola": "^2.9.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"html-minifier": "^4.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@ -14,10 +14,10 @@
|
||||
"chalk": "^2.4.2",
|
||||
"compression": "^1.7.4",
|
||||
"connect": "^3.7.0",
|
||||
"consola": "^2.7.1",
|
||||
"consola": "^2.9.0",
|
||||
"etag": "^1.8.1",
|
||||
"fresh": "^0.5.2",
|
||||
"fs-extra": "^8.0.1",
|
||||
"fs-extra": "^7.0.1",
|
||||
"ip": "^1.1.5",
|
||||
"launch-editor-middleware": "^2.2.1",
|
||||
"on-headers": "^1.0.2",
|
||||
|
@ -14,18 +14,18 @@
|
||||
"@types/etag": "^1.8.0",
|
||||
"@types/express": "^4.17.0",
|
||||
"@types/html-minifier": "^3.5.3",
|
||||
"@types/node": "^11.13.14",
|
||||
"@types/node": "^11.13.15",
|
||||
"@types/optimize-css-assets-webpack-plugin": "^1.3.4",
|
||||
"@types/serve-static": "^1.13.2",
|
||||
"@types/terser-webpack-plugin": "^1.2.1",
|
||||
"@types/webpack": "^4.4.32",
|
||||
"@types/webpack": "^4.4.34",
|
||||
"@types/webpack-bundle-analyzer": "^2.13.1",
|
||||
"@types/webpack-dev-middleware": "^2.0.2",
|
||||
"@types/webpack-dev-middleware": "^2.0.3",
|
||||
"@types/webpack-hot-middleware": "^2.16.5",
|
||||
"consola": "^2.7.1",
|
||||
"consola": "^2.9.0",
|
||||
"fork-ts-checker-webpack-plugin": "^1.3.7",
|
||||
"fs-extra": "^8.0.1",
|
||||
"ts-loader": "^6.0.2",
|
||||
"fs-extra": "^7.0.1",
|
||||
"ts-loader": "^6.0.4",
|
||||
"typescript": "^3.5.2"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -8,11 +8,11 @@
|
||||
],
|
||||
"main": "dist/utils.js",
|
||||
"dependencies": {
|
||||
"consola": "^2.7.1",
|
||||
"fs-extra": "^8.0.1",
|
||||
"consola": "^2.9.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"hash-sum": "^1.0.2",
|
||||
"proper-lockfile": "^4.1.1",
|
||||
"semver": "^6.1.1",
|
||||
"semver": "^6.1.2",
|
||||
"serialize-javascript": "^1.7.0",
|
||||
"signal-exit": "^3.0.2",
|
||||
"ua-parser-js": "^0.7.20"
|
||||
|
10
packages/vue-app/types/index.d.ts
vendored
10
packages/vue-app/types/index.d.ts
vendored
@ -9,6 +9,9 @@ import './process'
|
||||
// augment typings of Vue.js
|
||||
import './vue'
|
||||
|
||||
// augment typings of Vuex
|
||||
import './vuex'
|
||||
|
||||
type Dictionary<T> = { [key: string]: T }
|
||||
|
||||
type NuxtState = Dictionary<any>
|
||||
@ -39,7 +42,7 @@ export interface Context {
|
||||
res: ServerResponse
|
||||
redirect(status: number, path: string, query?: Route['query']): void
|
||||
redirect(path: string, query?: Route['query']): void
|
||||
error(params: ErrorParams): void
|
||||
error(params: NuxtError): void
|
||||
nuxtState: NuxtState
|
||||
beforeNuxtRender(fn: (params: { Components: VueRouter['getMatchedComponents'], nuxtState: NuxtState }) => void): void
|
||||
}
|
||||
@ -68,9 +71,10 @@ export interface Transition {
|
||||
leaveCancelled?(el: HTMLElement): void
|
||||
}
|
||||
|
||||
export interface ErrorParams {
|
||||
statusCode?: number
|
||||
export interface NuxtError {
|
||||
message?: string
|
||||
path?: string
|
||||
statusCode?: number
|
||||
}
|
||||
|
||||
export interface NuxtLoading extends Vue {
|
||||
|
10
packages/vue-app/types/vuex.d.ts
vendored
Normal file
10
packages/vue-app/types/vuex.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import Store from 'vuex'
|
||||
import VueRouter from 'vue-router'
|
||||
import { NuxtAppOptions } from '.'
|
||||
|
||||
declare module 'vuex/types/index' {
|
||||
interface Store<S> {
|
||||
app: NuxtAppOptions
|
||||
$router: VueRouter
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@
|
||||
"dependencies": {
|
||||
"@nuxt/devalue": "^1.2.3",
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"consola": "^2.7.1",
|
||||
"fs-extra": "^8.0.1",
|
||||
"consola": "^2.9.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"lru-cache": "^5.1.1",
|
||||
"vue": "^2.6.10",
|
||||
"vue-meta": "^1.6.0",
|
||||
|
@ -121,7 +121,7 @@ export default class SSRRenderer extends BaseRenderer {
|
||||
if (csp) {
|
||||
// Only add the hash if 'unsafe-inline' rule isn't present to avoid conflicts (#5387)
|
||||
const containsUnsafeInlineScriptSrc = csp.policies && csp.policies['script-src'] && csp.policies['script-src'].includes(`'unsafe-inline'`)
|
||||
if (!containsUnsafeInlineScriptSrc) {
|
||||
if (csp.unsafeInlineCompatiblity || !containsUnsafeInlineScriptSrc) {
|
||||
const hash = crypto.createHash(csp.hashAlgorithm)
|
||||
hash.update(serializedSession)
|
||||
cspScriptSrcHashes.push(`'${csp.hashAlgorithm}-${hash.digest('base64')}'`)
|
||||
|
@ -14,15 +14,14 @@
|
||||
"@nuxt/utils": "2.8.1",
|
||||
"babel-loader": "^8.0.6",
|
||||
"cache-loader": "^4.0.0",
|
||||
"caniuse-lite": "^1.0.30000974",
|
||||
"caniuse-lite": "^1.0.30000977",
|
||||
"chalk": "^2.4.2",
|
||||
"consola": "^2.7.1",
|
||||
"css-loader": "^2.1.1",
|
||||
"consola": "^2.9.0",
|
||||
"css-loader": "^3.0.0",
|
||||
"cssnano": "^4.1.10",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"extract-css-chunks-webpack-plugin": "^4.5.2",
|
||||
"file-loader": "^4.0.0",
|
||||
"fs-extra": "^8.0.1",
|
||||
"glob": "^7.1.4",
|
||||
"hard-source-webpack-plugin": "^0.13.1",
|
||||
"hash-sum": "^1.0.2",
|
||||
@ -41,15 +40,18 @@
|
||||
"terser-webpack-plugin": "^1.3.0",
|
||||
"thread-loader": "^2.1.2",
|
||||
"time-fix-plugin": "^2.0.6",
|
||||
"url-loader": "^2.0.0",
|
||||
"url-loader": "^2.0.1",
|
||||
"vue-loader": "^15.7.0",
|
||||
"webpack": "^4.34.0",
|
||||
"webpack": "^4.35.0",
|
||||
"webpack-bundle-analyzer": "^3.3.2",
|
||||
"webpack-dev-middleware": "^3.7.0",
|
||||
"webpack-hot-middleware": "^2.25.0",
|
||||
"webpack-node-externals": "^1.7.2",
|
||||
"webpackbar": "^3.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.9.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export default class StyleLoader {
|
||||
return this.buildContext.buildOptions.extractCSS
|
||||
}
|
||||
|
||||
get exportOnlyLocals() {
|
||||
get onlyLocals() {
|
||||
return Boolean(this.isServer && this.extractCSS)
|
||||
}
|
||||
|
||||
@ -68,10 +68,10 @@ export default class StyleLoader {
|
||||
}
|
||||
|
||||
css(options) {
|
||||
options.exportOnlyLocals = this.exportOnlyLocals
|
||||
options.onlyLocals = this.onlyLocals
|
||||
const cssLoader = { loader: 'css-loader', options }
|
||||
|
||||
if (options.exportOnlyLocals) {
|
||||
if (options.onlyLocals) {
|
||||
return [cssLoader]
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ export default class StyleLoader {
|
||||
}
|
||||
|
||||
cssModules(options) {
|
||||
return this.css(Object.assign(options, { modules: true }))
|
||||
return this.css(options)
|
||||
}
|
||||
|
||||
extract() {
|
||||
|
@ -6,7 +6,9 @@
|
||||
"dev"
|
||||
],
|
||||
"ignoreDeps": [
|
||||
"core-js"
|
||||
"core-js",
|
||||
// TODO: https://github.com/jprichardson/node-fs-extra/issues/687
|
||||
"fs-extra"
|
||||
],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true
|
||||
|
@ -34,7 +34,9 @@ describe('basic dev', () => {
|
||||
],
|
||||
loaders: {
|
||||
cssModules: {
|
||||
localIdentName: '[hash:base64:6]'
|
||||
modules: {
|
||||
localIdentName: '[hash:base64:6]'
|
||||
}
|
||||
}
|
||||
},
|
||||
extend({ module: { rules }, output: wpOutput }, { isClient, loaders }) {
|
||||
@ -92,7 +94,7 @@ describe('basic dev', () => {
|
||||
'css', 'cssModules', 'less', 'sass', 'scss', 'stylus', 'ts', 'tsx', 'vueStyle'
|
||||
)
|
||||
const { cssModules, vue } = loadersOptions
|
||||
expect(cssModules.localIdentName).toBe('[hash:base64:6]')
|
||||
expect(cssModules.modules.localIdentName).toBe('[hash:base64:6]')
|
||||
expect(vueLoader.options).toBe(vue)
|
||||
})
|
||||
|
||||
|
@ -196,7 +196,34 @@ describe('basic ssr csp', () => {
|
||||
expect(headers[cspHeader]).toMatch(/script-src 'self' 'unsafe-inline'$/)
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'Contain hash and \'unsafe-inline\' when unsafeInlineCompatiblity is enabled',
|
||||
async () => {
|
||||
const policies = {
|
||||
'script-src': [`'unsafe-inline'`]
|
||||
}
|
||||
|
||||
nuxt = await startCspServer({
|
||||
unsafeInlineCompatiblity: true,
|
||||
policies
|
||||
})
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await rp(url('/stateless'), {
|
||||
resolveWithFullResponse: true
|
||||
})
|
||||
}
|
||||
|
||||
const { headers } = await rp(url('/stateful'), {
|
||||
resolveWithFullResponse: true
|
||||
})
|
||||
|
||||
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
describe('debug mode', () => {
|
||||
test(
|
||||
'Not contain Content-Security-Policy-Report-Only header, when csp is false',
|
||||
@ -390,5 +417,31 @@ describe('basic ssr csp', () => {
|
||||
expect(headers[reportOnlyHeader]).toMatch(/script-src 'self' 'unsafe-inline'$/)
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'Contain hash and \'unsafe-inline\' when unsafeInlineCompatiblity is enabled',
|
||||
async () => {
|
||||
const policies = {
|
||||
'script-src': [`'unsafe-inline'`]
|
||||
}
|
||||
|
||||
nuxt = await startCspServer({
|
||||
unsafeInlineCompatiblity: true,
|
||||
policies
|
||||
})
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await rp(url('/stateless'), {
|
||||
resolveWithFullResponse: true
|
||||
})
|
||||
}
|
||||
|
||||
const { headers } = await rp(url('/stateful'), {
|
||||
resolveWithFullResponse: true
|
||||
})
|
||||
|
||||
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ describe('dynamic routes', () => {
|
||||
routerFile = routerFile
|
||||
.slice(routerFile.indexOf('routes: ['))
|
||||
.replace('routes: [', '[')
|
||||
.replace(/ _[0-9A-z]+,/g, ' "",')
|
||||
.replace(/ _[0-9A-Za-z]+,/g, ' "",')
|
||||
routerFile = routerFile.substr(
|
||||
routerFile.indexOf('['),
|
||||
routerFile.lastIndexOf(']') + 1
|
||||
|
@ -13,7 +13,7 @@ describe('route-name-splitter', () => {
|
||||
routerFile = routerFile
|
||||
.slice(routerFile.indexOf('routes: ['))
|
||||
.replace('routes: [', '[')
|
||||
.replace(/ _[0-9A-z]+,/g, ' "",')
|
||||
.replace(/ _[0-9A-Za-z]+,/g, ' "",')
|
||||
routerFile = routerFile.substr(
|
||||
routerFile.indexOf('['),
|
||||
routerFile.lastIndexOf(']') + 1
|
||||
|
@ -208,7 +208,7 @@ describe('with-config', () => {
|
||||
const { headers } = await rp(url('/test'), {
|
||||
resolveWithFullResponse: true
|
||||
})
|
||||
expect(headers['server-timing']).toMatch(/total;dur=\d+;desc="Nuxt Server Time"/)
|
||||
expect(headers['server-timing']).toMatch(/total;dur=\d+(\.\d+)?;desc="Nuxt Server Time"/)
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
|
Loading…
Reference in New Issue
Block a user