qatools-runner 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +12 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import fs from 'node:fs'
|
|
|
19
19
|
import os from 'node:os'
|
|
20
20
|
import path from 'node:path'
|
|
21
21
|
|
|
22
|
-
const VERSION = '0.1.
|
|
22
|
+
const VERSION = '0.1.1'
|
|
23
23
|
|
|
24
24
|
/* ── options ── */
|
|
25
25
|
const argv = process.argv.slice(2)
|
|
@@ -236,8 +236,17 @@ const server = http.createServer(async (req, res) => {
|
|
|
236
236
|
/open?code=… sets a same-site cookie, then the files load normally. */
|
|
237
237
|
if (req.method === 'GET' && url.pathname === '/open') {
|
|
238
238
|
if (!codeOk(url.searchParams.get('code'))) { res.writeHead(401, { 'content-type': 'text/plain' }).end('Wrong pairing code'); return }
|
|
239
|
-
const
|
|
240
|
-
|
|
239
|
+
const p = url.searchParams.get('p') ?? ''
|
|
240
|
+
const to = url.searchParams.get('to') === 'shot' && /^(test-results|playwright-report)\/[\w./ -]+$/.test(p) && !p.includes('..')
|
|
241
|
+
? `/files/${p.split('/').map(encodeURIComponent).join('/')}` : '/report/index.html'
|
|
242
|
+
/* Not a 302: the click started on qatools.dev, and browsers do not send a
|
|
243
|
+
SameSite=Strict cookie on a redirect that another site started. This page
|
|
244
|
+
sets the cookie, then moves on from OUR origin, so the cookie is sent. */
|
|
245
|
+
res.writeHead(200, {
|
|
246
|
+
'set-cookie': `qatools_runner=${CODE}; Path=/; HttpOnly; SameSite=Strict`,
|
|
247
|
+
'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', 'referrer-policy': 'no-referrer',
|
|
248
|
+
}).end(`<!doctype html><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=${to}"><title>Opening…</title>` +
|
|
249
|
+
`<p style="font:14px system-ui;padding:24px">Opening… <a href="${to}">continue</a></p><script>location.replace(${JSON.stringify(to)})</script>`)
|
|
241
250
|
return
|
|
242
251
|
}
|
|
243
252
|
if (req.method === 'GET' && (url.pathname.startsWith('/report/') || url.pathname.startsWith('/files/'))) {
|
package/package.json
CHANGED