Skip to content

Commit 18aea70

Browse files
authored
Merge pull request #1341 from solid/fix/1321
Fixed 1321 allowing for ranked accept mime types when requesting inde…
2 parents 0dadca0 + 1593a4c commit 18aea70

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/handlers/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function handler (req, res, next) {
4545

4646
let ret
4747
try {
48-
ret = await ldp.get(options, req.accepts('html'))
48+
ret = await ldp.get(options, req.accepts(['html', 'turtle', 'rdf+xml', 'n3', 'ld+json']) === 'html')
4949
} catch (err) {
5050
// use globHandler if magic is detected
5151
if (err.status === 404 && glob.hasMagic(path)) {

test/integration/http-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,20 @@ describe('HTTP APIs', function () {
379379
.expect('content-type', /text\/html/)
380380
.end(done)
381381
})
382+
it('should return turtle if requesting a conatiner that has index.html with conteent-type text/turtle', (done) => {
383+
server.get('/sampleContainer/')
384+
.set('accept', 'text/turtle')
385+
.expect(200)
386+
.expect('content-type', /text\/turtle/)
387+
.end(done)
388+
})
389+
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) => {
390+
server.get('/sampleContainer/')
391+
.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')
392+
.expect(200)
393+
.expect('content-type', /text\/turtle/)
394+
.end(done)
395+
})
382396
it('should still redirect to the right container URI if missing / and HTML is requested',
383397
function (done) {
384398
server.get('/sampleContainer')

0 commit comments

Comments
 (0)