From 1593a4c6cb2392ee01291fc89c53ac4d1683f6e6 Mon Sep 17 00:00:00 2001 From: jaxoncreed Date: Wed, 6 Nov 2019 16:57:35 -0500 Subject: [PATCH] Fixed 1321 allowing for ranked accept mime types when requesting index.html --- lib/handlers/get.js | 2 +- test/integration/http-test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/handlers/get.js b/lib/handlers/get.js index dfc9549bd..9ce9c614a 100644 --- a/lib/handlers/get.js +++ b/lib/handlers/get.js @@ -45,7 +45,7 @@ async function handler (req, res, next) { let ret try { - ret = await ldp.get(options, req.accepts('html')) + ret = await ldp.get(options, req.accepts(['html', 'turtle', 'rdf+xml', 'n3', 'ld+json']) === 'html') } catch (err) { // use globHandler if magic is detected if (err.status === 404 && glob.hasMagic(path)) { diff --git a/test/integration/http-test.js b/test/integration/http-test.js index 1df460360..972e2cf6e 100644 --- a/test/integration/http-test.js +++ b/test/integration/http-test.js @@ -379,6 +379,20 @@ describe('HTTP APIs', function () { .expect('content-type', /text\/html/) .end(done) }) + it('should return turtle if requesting a conatiner that has index.html with conteent-type text/turtle', (done) => { + server.get('/sampleContainer/') + .set('accept', 'text/turtle') + .expect(200) + .expect('content-type', /text\/turtle/) + .end(done) + }) + it('should return turtle if requesting a container that conatins an index.html file with a content type where some rdf format is ranked higher than html', (done) => { + server.get('/sampleContainer/') + .set('accept', 'image/*;q=0.9, */*;q=0.1, application/rdf+xml;q=0.9, application/xhtml+xml, text/xml;q=0.5, application/xml;q=0.5, text/html;q=0.9, text/plain;q=0.5, text/n3;q=1.0, text/turtle;q=1') + .expect(200) + .expect('content-type', /text\/turtle/) + .end(done) + }) it('should still redirect to the right container URI if missing / and HTML is requested', function (done) { server.get('/sampleContainer')