-
Notifications
You must be signed in to change notification settings - Fork 308
Resource-mapper now considers content type when inserting index.html #1260
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,7 @@ class ResourceMapper { | |
| if (!isIndex) { | ||
| match = files.find(f => this._removeDollarExtension(f) === filename) | ||
| // Check if the index file exists | ||
| } else if (files.includes(this._indexFilename)) { | ||
| } else if (files.includes(this._indexFilename) && contentType && contentType.includes(this._indexContentType)) { | ||
|
Contributor
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. Hmm. First of all, this can't be correct; the last condition will be true with However, I don't understand the intuition behind this line. What is is supposed to mean? The index file can only be served if the user agent "sends" a content type, that just so happens to be the content type of the index file? 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. Perhaps it is, because the contentType can have more values than „text/html” (IIRC a charset parameter or something). That's why an accept match isn't possible.
Contributor
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. I'd be surprised if a |
||
| match = this._indexFilename | ||
| } | ||
| } | ||
|
|
||
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.
(See comment below first.)
Is
options.contentTypethe value of theAcceptheader? Then it's not a content type, so can't be passed. But in any case, passing the content type to the resource mapper is only meaningful in the case ofPUTorPOST, when a new URL needs to be created; the mapper does not do content negotiation.It seems to me that the desired logic should be implemented at this level, perhaps as follows:
searchIndextofalseif theAcceptheader does not explicitly ask fortext/html.mapUrlToFile.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.
Ah okay thanks. I'll do that