-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Update MiniBrowserEndpoint.defaultHandler() response to return content even when file type is not exists at mime-db #7356
Update MiniBrowserEndpoint.defaultHandler() response to return content even when file type is not exists at mime-db #7356
Conversation
@i501378 please be sure to sign the Eclipse ECA using the same email as your |
@@ -180,7 +180,7 @@ export class MiniBrowserEndpoint implements BackendApplicationContribution, Mini | |||
const mimeType = lookup(FileUri.fsPath(stat.uri)); | |||
if (!mimeType) { | |||
this.logger.warn(`Cannot handle unexpected resource. URI: ${statWithContent.stat.uri}.`); | |||
return response.send(); | |||
return response.send(content); |
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.
Please
if (!mimeType) {
this.logger.warn(`Cannot handle unexpected resource. URI: ${statWithContent.stat.uri}.`);
response.contentType('application/octet-stream');
} else {
response.contentType(mimeType);
}
return response.send(content);
Updated.
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.
According to mime-type
:
No fallbacks. Instead of naively returning the first available type, mime-types simply returns false, so do var type = mime.lookup('unrecognized') || 'application/octet-stream'.
I have updated my snippet above 👆
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.
@kittaakos Do we need to log warning? We don't have it for webviews and so far nobody complained.
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.
Do we need to log warning? We don't have it for webviews and so far nobody complained.
I do not have a strong preference; if you feel we need it, please proceed. Otherwise, we can merge the PR.
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.
It is to avoid unnecessary noise. I'm fine with merging as is.
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.
Nice, it works nicely. I do not mind changing this behavior. @i501378, please squash your commits into one and then we can merge it. Thanks! 👍
…t when file type is not exists at mime-db Signed-off-by: Lital Gilboa <lital.gilboa@sap.com>
What it does
Support other mime type files to be fetched on mini browser preview.
How to test
test.zip
Upload the file and unzip it into the root of workspace.
Right click on test.html file and select "Open With" -> "Preview"
The "TITLE" and "SUBTITLE" are replaced by the related translation texts from i18n.properties file.
Fixes #7231
Review checklist
Reminder for reviewers