-
Notifications
You must be signed in to change notification settings - Fork 303
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
fix issues #1120 #1256 from NSS5.1.6 ressource-mapper #1282
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
58e1a47
allow slug with extension
bourgeoa 05153ae
delete allow slug with extension
bourgeoa 9abcbb9
fix to ressource-mapper and slug with extension
bourgeoa 2f0ce48
correction of add /lib/get.js by mistake
bourgeoa 80f7aea
do not add extention to .acl or .meta files
bourgeoa 4b8c079
do not add extention to .acl or .meta files
bourgeoa 1c5038c
resolve package-lock.json
bourgeoa 85ee73b
simplify double if in resource-mapper.js
bourgeoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ const HTTPError = require('./http-error') | |
|
||
/* | ||
* A ResourceMapper maintains the mapping between HTTP URLs and server filenames, | ||
* following the principles of the “sweet spot” discussed in | ||
* following the principles of the "sweet spot" discussed in | ||
* https://www.w3.org/DesignIssues/HTTPFilenameMapping.html | ||
* | ||
* This class implements this mapping in a single place | ||
|
@@ -91,22 +91,24 @@ class ResourceMapper { | |
if (filePath.indexOf('/..') >= 0) { | ||
throw new Error('Disallowed /.. segment in URL') | ||
} | ||
let isIndex = searchIndex && filePath.endsWith('/') | ||
let isFolder = filePath.endsWith('/') | ||
|
||
// Create the path for a new file | ||
// Create the path for a new ressource | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
let path | ||
if (createIfNotExists) { | ||
path = filePath | ||
// Append index filename if needed | ||
if (isIndex) { | ||
if (searchIndex && isFolder) { | ||
if (contentType !== this._indexContentType) { | ||
throw new Error(`Index file needs to have ${this._indexContentType} as content type`) | ||
} | ||
path += this._indexFilename | ||
} | ||
// If the extension is not correct for the content type, append the correct extension | ||
if (searchIndex && this._getContentTypeByExtension(path) !== contentType) { | ||
path += `$${contentType in extensions ? `.${extensions[contentType][0]}` : '.unknown'}` | ||
if (!isFolder) { | ||
if (this._getContentTypeByExtension(path) !== contentType) { | ||
path += `$${contentType in extensions ? `.${extensions[contentType][0]}` : '.unknown'}` | ||
} | ||
} | ||
// Determine the path of an existing file | ||
} else { | ||
|
@@ -116,23 +118,15 @@ class ResourceMapper { | |
|
||
// Find a file with the same name (minus the dollar extension) | ||
let match = '' | ||
if (searchIndex) { | ||
const files = await this._readdir(folder) | ||
// Search for files with the same name (disregarding a dollar extension) | ||
if (!isIndex) { | ||
match = files.find(f => this._removeDollarExtension(f) === filename) | ||
// Check if the index file exists | ||
} else if (files.includes(this._indexFilename)) { | ||
match = this._indexFilename | ||
} | ||
} | ||
// 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}`) | ||
} | ||
const files = await this._readdir(folder) | ||
// Search for files with the same name (disregarding a dollar extension) | ||
if (!isFolder) { | ||
match = files.find(f => this._removeDollarExtension(f) === filename) | ||
if (match === undefined) { throw new HTTPError(404, `Resource not found: ${pathname}`) } | ||
|
||
// Check if the index file exists | ||
} else if (searchIndex && files.includes(this._indexFilename)) { | ||
match = this._indexFilename | ||
} | ||
path = `${folder}${match}` | ||
contentType = this._getContentTypeByExtension(match) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be better handled as
so that we can handle requests where rdf has a higher weighted q value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall I push your proposal (might be better ?) or do we keep it like it is ?
__
Just tried your proposal locally and
npm run test
, it fails on :So I propose to leave it like it is for node-solid-server EOL