move url replacement
This commit is contained in:
parent
486cd3a6eb
commit
6e37ea1423
|
|
@ -81,19 +81,16 @@ export class ZipTraceModelBackend implements TraceModelBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FetchTraceModelBackend implements TraceModelBackend {
|
export class FetchTraceModelBackend implements TraceModelBackend {
|
||||||
private _entriesPromise: Promise<Map<string, URL>>;
|
private _entriesPromise: Promise<Map<string, string>>;
|
||||||
private _traceURL: string;
|
private _traceURL: string;
|
||||||
|
|
||||||
constructor(traceURL: string) {
|
constructor(traceURL: string) {
|
||||||
this._traceURL = traceURL;
|
this._traceURL = traceURL;
|
||||||
this._entriesPromise = fetch(traceURL).then(async response => {
|
this._entriesPromise = fetch(traceURL).then(async response => {
|
||||||
const json = JSON.parse(await response.text());
|
const json = JSON.parse(await response.text());
|
||||||
const entries = new Map<string, URL>();
|
const entries = new Map<string, string>();
|
||||||
for (const entry of json.entries) {
|
for (const entry of json.entries)
|
||||||
const entryURL = new URL(traceURL);
|
entries.set(entry.name, entry.path);
|
||||||
entryURL.searchParams.set('path', entry.path);
|
|
||||||
entries.set(entry.name, entryURL);
|
|
||||||
}
|
|
||||||
return entries;
|
return entries;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -128,9 +125,12 @@ export class FetchTraceModelBackend implements TraceModelBackend {
|
||||||
|
|
||||||
private async _readEntry(entryName: string): Promise<Response | undefined> {
|
private async _readEntry(entryName: string): Promise<Response | undefined> {
|
||||||
const entries = await this._entriesPromise;
|
const entries = await this._entriesPromise;
|
||||||
const fileURL = entries.get(entryName);
|
const filePath = entries.get(entryName);
|
||||||
if (!fileURL)
|
if (!filePath)
|
||||||
return;
|
return;
|
||||||
return fetch(fileURL);
|
|
||||||
|
const url = new URL(this.traceURL());
|
||||||
|
url.searchParams.set('path', filePath);
|
||||||
|
return fetch(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue