Skip to content

Commit 5119002

Browse files
committed
server: adjust indentation, add 404 to "custom server" test case
Follows-up 4f73f34.
1 parent 4f73f34 commit 5119002

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/server.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -432,21 +432,23 @@ class ControlServer {
432432
// transparent and correct.
433433
// * Ignore <heading> and <head-thing>.
434434
// * Support <head x=y...>, including with tabs or newlines before ">".
435-
html = util.replaceOnce(html, [
436-
/<head(?:\s[^>]*)?>/i,
437-
/<html(?:\s[^>]*)?>/i,
438-
/<!doctype[^>]*>/i,
439-
/^/
440-
],
441-
(m) => m + headInjectHtml
435+
html = util.replaceOnce(html,
436+
[
437+
/<head(?:\s[^>]*)?>/i,
438+
/<html(?:\s[^>]*)?>/i,
439+
/<!doctype[^>]*>/i,
440+
/^/
441+
],
442+
(m) => m + headInjectHtml
442443
);
443444

444-
html = util.replaceOnce(html, [
445-
/<\/body>(?![\s\S]*<\/body>)/i,
446-
/<\/html>(?![\s\S]*<\/html>)/i,
447-
/$/
448-
],
449-
(m) => '<script>(' + util.fnToStr(qtapClientBody, qtapTapUrl) + ')();</script>' + m
445+
html = util.replaceOnce(html,
446+
[
447+
/<\/body>(?![\s\S]*<\/body>)/i,
448+
/<\/html>(?![\s\S]*<\/html>)/i,
449+
/$/
450+
],
451+
(m) => '<script>(' + util.fnToStr(qtapClientBody, qtapTapUrl) + ')();</script>' + m
450452
);
451453

452454
return {

test/qtap.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,16 @@ QUnit.module('qtap', function (hooks) {
506506
assert.timeout(40_000);
507507

508508
const server = http.createServer((req, resp) => {
509-
resp.writeHead(200);
510-
resp.end(
511-
'# console: Origin server URL is ' + req.url + '\n'
512-
+ 'TAP version 13\nok 1 Foo\nok 2 Bar\n1..2\n'
513-
);
509+
if (req.url.startsWith('/test/example.html')) {
510+
resp.writeHead(200);
511+
resp.end(
512+
'# console: Origin server URL is ' + req.url + '\n'
513+
+ 'TAP version 13\nok 1 Foo\nok 2 Bar\n1..2\n'
514+
);
515+
} else {
516+
resp.writeHead(404);
517+
resp.end('Not Found\n');
518+
}
514519
});
515520
server.listen();
516521
const port = await new Promise((resolve) => {

0 commit comments

Comments
 (0)