Fix loading of webview resources that depend on query params
Some resource url (notably git) use the query part of the url to store additional information. The query part of the url was incorrectly being dropped while attempting to load these resources inside of webviews
This commit is contained in:
parent
eac3821fbf
commit
48387dfc3d
2 changed files with 5 additions and 2 deletions
|
@ -210,10 +210,12 @@ export abstract class BaseWebview<T extends HTMLElement> extends Disposable {
|
|||
this.handleKeyEvent('keyup', data);
|
||||
}));
|
||||
|
||||
this._register(this.on(WebviewMessageChannels.loadResource, (entry: any) => {
|
||||
this._register(this.on(WebviewMessageChannels.loadResource, (entry: { id: number, path: string, query: string, ifNoneMatch?: string }) => {
|
||||
const rawPath = entry.path;
|
||||
const normalizedPath = decodeURIComponent(rawPath);
|
||||
const uri = URI.parse(normalizedPath.replace(/^\/([\w\-]+)\/(.+)$/, (_, scheme, path) => scheme + ':/' + path));
|
||||
const uri = URI.parse(normalizedPath.replace(/^\/([\w\-]+)\/(.+)$/, (_, scheme, path) => scheme + ':/' + path)).with({
|
||||
query: decodeURIComponent(entry.query),
|
||||
});
|
||||
this.loadResource(entry.id, rawPath, uri, entry.ifNoneMatch);
|
||||
}));
|
||||
|
||||
|
|
|
@ -255,6 +255,7 @@ async function processResourceRequest(event, requestUrl) {
|
|||
channel: 'load-resource',
|
||||
id: requestId,
|
||||
path: resourcePath,
|
||||
query: requestUrl.search.replace(/^\?/, ''),
|
||||
ifNoneMatch: cached?.headers.get('ETag'),
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue