diff --git a/package-lock.json b/package-lock.json index 4d8e304705..5501af5233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "chokidar": "^3.5.3", "colorette": "^2.0.10", "compression": "^1.7.4", - "connect-history-api-fallback": "^1.6.0", + "connect-history-api-fallback": "^2.0.0", "default-gateway": "^6.0.3", "express": "^4.17.3", "graceful-fs": "^4.2.6", @@ -5053,9 +5053,9 @@ } }, "node_modules/connect-history-api-fallback": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", - "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz", + "integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==", "engines": { "node": ">=0.8" } @@ -19394,9 +19394,9 @@ } }, "connect-history-api-fallback": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", - "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz", + "integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==" }, "content-disposition": { "version": "0.5.4", diff --git a/package.json b/package.json index fb39533d57..689ec8ef19 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "chokidar": "^3.5.3", "colorette": "^2.0.10", "compression": "^1.7.4", - "connect-history-api-fallback": "^1.6.0", + "connect-history-api-fallback": "^2.0.0", "default-gateway": "^6.0.3", "express": "^4.17.3", "graceful-fs": "^4.2.6", diff --git a/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack4 b/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack4 index bace5c10a6..4eb7c58edf 100644 --- a/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack4 @@ -130,6 +130,15 @@ exports[`historyApiFallback option as object with the "verbose" option request t " `; +exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response status 1`] = `"OK"`; + +exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response text 1`] = ` +"In-memory file +" +`; + exports[`historyApiFallback option in-memory files should take precedence over static files: console messages 1`] = `Array []`; exports[`historyApiFallback option in-memory files should take precedence over static files: page errors 1`] = `Array []`; diff --git a/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 b/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 index bace5c10a6..4eb7c58edf 100644 --- a/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 @@ -130,6 +130,15 @@ exports[`historyApiFallback option as object with the "verbose" option request t " `; +exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response status 1`] = `"OK"`; + +exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response text 1`] = ` +"In-memory file +" +`; + exports[`historyApiFallback option in-memory files should take precedence over static files: console messages 1`] = `Array []`; exports[`historyApiFallback option in-memory files should take precedence over static files: page errors 1`] = `Array []`; diff --git a/test/e2e/history-api-fallback.test.js b/test/e2e/history-api-fallback.test.js index bbd1f7755d..2f20a7335a 100644 --- a/test/e2e/history-api-fallback.test.js +++ b/test/e2e/history-api-fallback.test.js @@ -643,5 +643,45 @@ describe("historyApiFallback option", () => { expect(pageErrors).toMatchSnapshot("page errors"); }); + + it("should perform HEAD request in same way as GET", async () => { + await page.goto(`http://127.0.0.1:${port}/foo`, { + waitUntil: "networkidle0", + }); + + const responseGet = await page.evaluate(async () => { + const response = await fetch("/foo", { method: "GET" }); + + return { + contentType: response.headers.get("content-type"), + statusText: response.statusText, + text: await response.text(), + }; + }); + + expect(responseGet.contentType).toMatchSnapshot( + "response headers content-type" + ); + + expect(responseGet.statusText).toMatchSnapshot("response status"); + + expect(responseGet.text).toMatchSnapshot("response text"); + + const responseHead = await page.evaluate(async () => { + const response = await fetch("/foo", { method: "HEAD" }); + + return { + contentType: response.headers.get("content-type"), + statusText: response.statusText, + text: await response.text(), + }; + }); + + expect(responseHead).toMatchObject({ + ...responseGet, + // HEAD response has an empty body + text: "", + }); + }); }); });