Skip to content

Commit 3b85808

Browse files
committed
Fix to make files with no file extension be rec as turtle by default
1 parent d1b15da commit 3b85808

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/handlers/get.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const translate = require('../utils.js').translate
1717
const error = require('../http-error')
1818

1919
const RDFs = require('../ldp').RDF_MIME_TYPES
20+
const LegacyResourceMapper = require('../legacy-resource-mapper')
2021

2122
function handler (req, res, next) {
2223
const ldp = req.app.locals.ldp
@@ -76,7 +77,13 @@ function handler (req, res, next) {
7677
// Till here it must exist
7778
if (!includeBody) {
7879
debug('HEAD only')
79-
contentType = mime.contentType(_path.extname(path))
80+
const rootUrl = utils.getBaseUri(req)
81+
const mapper = new LegacyResourceMapper({
82+
rootUrl,
83+
rootPath: ldp.root,
84+
includeHost: ldp.multiuser
85+
})
86+
contentType = mapper._getContentTypeByExtension(path)
8087
res.setHeader('Content-Type', contentType)
8188
res.status(200).send('OK')
8289
return next()

test/integration/http-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ describe('HTTP APIs', function () {
368368
})
369369

370370
describe('HEAD API', function () {
371+
it('should return content-type turtle by default', function (done) {
372+
server.head('/sampleContainer/blank')
373+
.expect('Content-Type', 'text/turtle; charset=utf-8')
374+
.end(done)
375+
})
371376
it('should have set content-type for turtle files',
372377
function (done) {
373378
server.head('/sampleContainer/example1.ttl')

test/resources/sampleContainer/blank

Whitespace-only changes.

0 commit comments

Comments
 (0)