Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 on non existent container path #1762

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class LDP {
({ path, contentType } = await this.resourceMapper.mapUrlToFile({ url: options, searchIndex }))
stats = await this.stat(path)
} catch (err) {
throw error(404, 'Can\'t find file requested: ' + options)
throw error(err.status || 500, err.message)
}

// Just return, since resource exists
Expand Down
6 changes: 4 additions & 2 deletions lib/resource-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ResourceMapper {

// Find a file with the same name (minus the dollar extension)
let match = ''
if (match === '') { // always true to keep indentation
try {
const files = await this._readdir(folder)
// Search for files with the same name (disregarding a dollar extension)
if (!isFolder) {
Expand All @@ -134,13 +134,15 @@ class ResourceMapper {
} else if (searchIndex && files.includes(this._indexFilename)) {
match = this._indexFilename
}
} catch (err) {
throw new HTTPError(404, `${filePath} Resource not found`)
}
// Error if no match was found (unless URL ends with '/', then fall back to the folder)
if (match === undefined) {
if (isIndex) {
match = ''
} else {
throw new HTTPError(404, `Resource not found: ${pathname}`)
throw new HTTPError(404, `${pathname} Resource not found`)
}
}
path = `${folder}${match}`
Expand Down
Loading
Loading