Unverified Commit ff9dcc6a authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure custom app regex is correct for Windows (#28631)

* Ensure custom app regex is correct for Windows

* lint-fix

* update test for ie

* update test

* lint-fix
parent 9be387c7
...@@ -1561,7 +1561,9 @@ export default async function getBaseWebpackConfig( ...@@ -1561,7 +1561,9 @@ export default async function getBaseWebpackConfig(
webpackConfig = await buildConfiguration(webpackConfig, { webpackConfig = await buildConfiguration(webpackConfig, {
rootDirectory: dir, rootDirectory: dir,
customAppFile: new RegExp(path.join(pagesDir, `_app`)), customAppFile: new RegExp(
path.join(pagesDir, `_app`).replace(/\\/g, '(/|\\\\)')
),
isDevelopment: dev, isDevelopment: dev,
isServer, isServer,
assetPrefix: config.assetPrefix || '', assetPrefix: config.assetPrefix || '',
......
...@@ -64,7 +64,7 @@ function runTests(dev) { ...@@ -64,7 +64,7 @@ function runTests(dev) {
if (!dev) { if (!dev) {
// Ensure only `/blue` page's CSS is preloaded // Ensure only `/blue` page's CSS is preloaded
const serverCssPreloads = $('link[rel="preload"][as="style"]') const serverCssPreloads = $('link[rel="preload"][as="style"]')
expect(serverCssPreloads.length).toBe(1) expect(serverCssPreloads.length).toBe(2)
const serverCssPrefetches = $('link[rel="prefetch"][as="style"]') const serverCssPrefetches = $('link[rel="prefetch"][as="style"]')
expect(serverCssPrefetches.length).toBe(0) expect(serverCssPrefetches.length).toBe(0)
......
import './global.css'
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
/* eslint-env jest */ /* eslint-env jest */
/* global browserName */
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { readFileSync } from 'fs' import { readFileSync } from 'fs'
import url from 'url' import url from 'url'
...@@ -343,14 +344,15 @@ module.exports = (context) => { ...@@ -343,14 +344,15 @@ module.exports = (context) => {
expect(hostname).not.toBe('example.com') expect(hostname).not.toBe('example.com')
}) })
if (browserName !== 'internet explorer') {
it('should not execute script embedded inside svg image', async () => { it('should not execute script embedded inside svg image', async () => {
let browser let browser
try { try {
browser = await webdriver(context.appPort, '/svg-image') browser = await webdriver(context.appPort, '/svg-image')
await browser.eval(`document.getElementById("img").scrollIntoView()`) await browser.eval(`document.getElementById("img").scrollIntoView()`)
expect(await browser.elementById('img').getAttribute('src')).toContain( expect(
'xss.svg' await browser.elementById('img').getAttribute('src')
) ).toContain('xss.svg')
expect(await browser.elementById('msg').text()).toBe('safe') expect(await browser.elementById('msg').text()).toBe('safe')
browser = await webdriver( browser = await webdriver(
context.appPort, context.appPort,
...@@ -361,5 +363,6 @@ module.exports = (context) => { ...@@ -361,5 +363,6 @@ module.exports = (context) => {
if (browser) await browser.close() if (browser) await browser.close()
} }
}) })
}
}) })
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment