Skip to content

Commit 2e39e97

Browse files
committed
404 on non existent container path
1 parent 74133e6 commit 2e39e97

File tree

5 files changed

+435
-189
lines changed

5 files changed

+435
-189
lines changed

lib/ldp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class LDP {
448448
({ path, contentType } = await this.resourceMapper.mapUrlToFile({ url: options, searchIndex }))
449449
stats = await this.stat(path)
450450
} catch (err) {
451-
throw error(404, 'Can\'t find file requested: ' + options)
451+
throw error(err.status || 500, err.message)
452452
}
453453

454454
// Just return, since resource exists

lib/resource-mapper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ResourceMapper {
125125

126126
// Find a file with the same name (minus the dollar extension)
127127
let match = ''
128-
if (match === '') { // always true to keep indentation
128+
try {
129129
const files = await this._readdir(folder)
130130
// Search for files with the same name (disregarding a dollar extension)
131131
if (!isFolder) {
@@ -134,13 +134,15 @@ class ResourceMapper {
134134
} else if (searchIndex && files.includes(this._indexFilename)) {
135135
match = this._indexFilename
136136
}
137+
} catch (err) {
138+
throw new HTTPError(404, `${filePath} Resource not found`)
137139
}
138140
// Error if no match was found (unless URL ends with '/', then fall back to the folder)
139141
if (match === undefined) {
140142
if (isIndex) {
141143
match = ''
142144
} else {
143-
throw new HTTPError(404, `Resource not found: ${pathname}`)
145+
throw new HTTPError(404, `${pathname} Resource not found`)
144146
}
145147
}
146148
path = `${folder}${match}`

0 commit comments

Comments
 (0)