Skip to content

Commit 599ffd8

Browse files
committed
Add test case
1 parent 9a288d6 commit 599ffd8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

test/markdown-link-check.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ describe('markdown-link-check', function () {
5353
res.json({foo:'bar'});
5454
});
5555

56+
app.use('/redirect-with-body-in-head', function (req, res) {
57+
/* Don't judge me. I found at least one server on the
58+
* Internet doing this and it triggered a bug. */
59+
const body = 'Let me send you a body, although you only asked for a HEAD.';
60+
61+
const headers =
62+
'HTTP/1.1 302 Found\r\n' +
63+
'Connection: close\r\n' +
64+
'Location: /foo/bar\r\n' +
65+
`Content-Length: ${Buffer.byteLength(body)}\r\n` +
66+
'\r\n';
67+
68+
res.socket.write(headers + body);
69+
res.socket.destroy();
70+
});
71+
5672
app.get('/basic-auth', function (req, res) {
5773
if (req.headers["authorization"] === "Basic Zm9vOmJhcg==") {
5874
res.sendStatus(200);
@@ -110,6 +126,9 @@ describe('markdown-link-check', function () {
110126
expect(results).to.be.an('array');
111127

112128
const expected = [
129+
// redirect-with-body-in-head
130+
{ statusCode: 200, status: 'alive' },
131+
113132
// redirect-loop
114133
{ statusCode: 0, status: 'dead' },
115134

test/sample.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
This is a test file:
44

5+
* [redirect-with-body-in-head](%%BASE_URL%%/redirect-with-body-in-head) (alive)
56
* [redirect-loop](%%BASE_URL%%/loop) (dead)
67
* [valid](%%BASE_URL%%/foo/bar) (alive)
78
* [invalid](%%BASE_URL%%/foo/dead) (dead)

0 commit comments

Comments
 (0)