Correct identification of uri scheme according to rfc3986 #8832
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.
What it does
This changes proposal fix identification of uri scheme. The problem is in regular expression, that matches uri scheme, it is trying to find scheme according to pattern
\w+
which matches any word character (alphanumeric and underscore).According to https://tools.ietf.org/html/rfc3986#section-3.1 underscore cannot be used as part of uri scheme:
Proposed changes is to align matching to rfc specification and use regular expression:
/^\/([a-zA-Z0-9.\-+]+)\/(.+)$/
instead of/^\/(\w+)\/(.+)$/
.This might be helpful for extensions, that provides custom resource scheme instead of
vscode-resource://
. Especially when extension that provides webview is located in different container/user machine and content to the remote resource is given by provided scheme.Signed-off-by: Vladyslav Zhukovskyi vzhukovs@redhat.com
How to test
To check this Theia has to be run in multi-container environment, like OpenShift: create and run workspace.
This workspace configuration also provides an extension that runs in dedicate container: redhat.vscode-didact.
After workspace start try to open any sample didact tutorial, resources from this webview (js, css) will be loaded using different uri scheme and webview will be displayed the same way as it runs locally on single node environment.
Review checklist
Reminder for reviewers