diff --git a/src/index.js b/src/index.js index 9a8a824..85bbe76 100644 --- a/src/index.js +++ b/src/index.js @@ -24,6 +24,8 @@ const etags = new Map(); const calculateSha = (handlers, absolutePath) => new Promise((resolve, reject) => { const hash = createHash('sha1'); + hash.update(path.extname(absolutePath)); + hash.update('-'); const rs = handlers.createReadStream(absolutePath); rs.on('error', reject); rs.on('data', buf => hash.update(buf)); diff --git a/test/fixtures/docs.txt b/test/fixtures/docs.txt new file mode 100644 index 0000000..4dbb717 --- /dev/null +++ b/test/fixtures/docs.txt @@ -0,0 +1 @@ +## This is a markdown file diff --git a/test/integration.js b/test/integration.js index 756537b..61b812b 100644 --- a/test/integration.js +++ b/test/integration.js @@ -1331,14 +1331,22 @@ test('allow symlinks by setting the option', async t => { }); test('etag header is set', async t => { - const directory = 'single-directory'; const url = await getUrl({ renderSingle: true, etag: true }); - const response = await fetch(`${url}/${directory}`); + + let response = await fetch(`${url}/docs.md`); + t.is(response.status, 200); + t.is( + response.headers.get('etag'), + '"60be4422531fce1513df34cbcc90bed5915a53ef"' + ); + + response = await fetch(`${url}/docs.txt`); + t.is(response.status, 200); t.is( response.headers.get('etag'), - '"4e5f19df3bfe8db7d588edfc3960991aa0715ccf"' + '"ba114dbc69e41e180362234807f093c3c4628f90"' ); });