Skip to content

Commit 095b0d6

Browse files
committed
Fixed content type mismatch at root
1 parent cf41de2 commit 095b0d6

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/handlers/get.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ async function handler (req, res, next) {
3939
'path': path,
4040
'includeBody': includeBody,
4141
'possibleRDFType': possibleRDFType,
42-
'range': req.headers.range
42+
'range': req.headers.range,
43+
'contentType': req.headers.accept
4344
}
4445

4546
let ret

lib/ldp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ class LDP {
329329
async get (options, searchIndex = true) {
330330
let path, contentType, stats
331331
try {
332-
({ path, contentType } = await this.resourceMapper.mapUrlToFile({ url: options, searchIndex }))
332+
({ path, contentType } = await this.resourceMapper.mapUrlToFile({
333+
url: options, contentType: options.contentType, searchIndex
334+
}))
333335
stats = await this.stat(path)
334336
} catch (err) {
335337
throw error(404, 'Can\'t find file requested: ' + options)

lib/resource-mapper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class ResourceMapper {
5555
}
5656
fullPath += this._indexFilename
5757
}
58-
5958
// Create the path for a new file
6059
if (createIfNotExists) {
6160
path = fullPath
@@ -70,7 +69,11 @@ class ResourceMapper {
7069
const folder = fullPath.substr(0, fullPath.length - filename.length)
7170

7271
// Find a file with the same name (minus the dollar extension)
73-
let match = searchIndex ? await this._getMatchingFile(folder, filename, isIndex) : ''
72+
let match = searchIndex ? await this._getMatchingFile(folder, filename, isIndex) : '';
73+
// Do not match with html if the content type won't allow it
74+
if (!(contentType.includes('text/html') || contentType.includes('*/*'))) {
75+
match = '';
76+
}
7477
if (match === undefined) {
7578
// Error if no match was found,
7679
// unless the URL ends with a '/',

0 commit comments

Comments
 (0)