Skip to content

Commit

Permalink
revert "Remove leading slash of webview route ..."
Browse files Browse the repository at this point in the history
partially reverting changes from eclipse-theia#5619 which break "html base href" logic in webview for instance in the python extension for vscode.

Signed-off-by: Alex Tugarev <alex.tugarev@typefox.io>
  • Loading branch information
AlexTugarev authored and akosyakov committed Feb 24, 2020
1 parent f54cf61 commit d720ba8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIF
// redefine property
Object.defineProperty(panel.webview, 'html', {
set: function (html: string): void {
const newHtml = html.replace(new RegExp('vscode-resource:/', 'g'), 'webview/');
const newHtml = html.replace(new RegExp('vscode-resource:/', 'g'), '/webview/');
this.checkIsDisposed();
if (this._html !== newHtml) {
this._html = newHtml;
Expand All @@ -74,7 +74,7 @@ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIF
const originalPostMessage = panel.webview.postMessage;
panel.webview.postMessage = (message: any): PromiseLike<boolean> => {
const decoded = JSON.stringify(message);
const newMessage = decoded.replace(new RegExp('vscode-resource:/', 'g'), 'webview/');
const newMessage = decoded.replace(new RegExp('vscode-resource:/', 'g'), '/webview/');
return originalPostMessage.call(panel.webview, JSON.parse(newMessage));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ThemeRulesService {
path = this.isDark() ? value.dark : value.light;
}
if (path.startsWith('/')) {
path = `webview${path}`;
path = `/webview${path}`;
}
cssRules.push(`.webview-icon.${key}-file-icon::before { background-image: url(${path}); }`);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/plugin/webviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class WebviewImpl implements theia.Webview {
this.checkIsDisposed();
// replace theia-resource: content in the given message
const decoded = JSON.stringify(message);
let newMessage = decoded.replace(new RegExp('theia-resource:/', 'g'), 'webview/');
let newMessage = decoded.replace(new RegExp('theia-resource:/', 'g'), '/webview/');
if (this._options && this._options.localResourceRoots) {
newMessage = this.filterLocalRoots(newMessage, this._options.localResourceRoots);
}
Expand Down Expand Up @@ -191,7 +191,7 @@ export class WebviewImpl implements theia.Webview {
}

set html(html: string) {
let newHtml = html.replace(new RegExp('theia-resource:/', 'g'), 'webview/');
let newHtml = html.replace(new RegExp('theia-resource:/', 'g'), '/webview/');
if (this._options && this._options.localResourceRoots) {
newHtml = this.filterLocalRoots(newHtml, this._options.localResourceRoots);
}
Expand Down

0 comments on commit d720ba8

Please sign in to comment.