Skip to content

Commit 417bf13

Browse files
committed
Merge branch 'resourceMapper' of https://github.com/solid/node-solid-server into main
2 parents a8bf8c4 + b00726f commit 417bf13

File tree

4 files changed

+266
-97
lines changed

4 files changed

+266
-97
lines changed

lib/ldp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class LDP {
459459
({ path, contentType } = await this.resourceMapper.mapUrlToFile({ url: options, searchIndex }))
460460
stats = await this.stat(path)
461461
} catch (err) {
462-
throw error(404, 'Can\'t find file requested: ' + options)
462+
throw error(err.status || 500, err.message)
463463
}
464464

465465
// Just return, since resource exists

lib/resource-mapper.js

+4-2
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)