From a87d729e2f1e07c924057486df002c4c2f367bda Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 24 Oct 2024 13:44:50 +0200 Subject: [PATCH] refactor formatURL --- packages/trace-viewer/src/sw/traceModelBackends.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/trace-viewer/src/sw/traceModelBackends.ts b/packages/trace-viewer/src/sw/traceModelBackends.ts index 15ff6f8308..4f5bd49624 100644 --- a/packages/trace-viewer/src/sw/traceModelBackends.ts +++ b/packages/trace-viewer/src/sw/traceModelBackends.ts @@ -31,7 +31,7 @@ export class ZipTraceModelBackend implements TraceModelBackend { constructor(traceURL: string, progress: Progress) { this._traceURL = traceURL; this._zipReader = new zipjs.ZipReader( - new zipjs.HttpReader(formatUrl(traceURL), { mode: 'cors', preventHeadRequest: true } as any), + new zipjs.HttpReader(formatTraceFileUrl(traceURL), { mode: 'cors', preventHeadRequest: true } as any), { useWebWorkers: false }); this._entriesPromise = this._zipReader.getEntries({ onprogress: progress }).then(entries => { const map = new Map(); @@ -86,7 +86,7 @@ export class FetchTraceModelBackend implements TraceModelBackend { constructor(traceURL: string) { this._traceURL = traceURL; - this._entriesPromise = fetch(formatUrl(traceURL)).then(async response => { + this._entriesPromise = fetch(formatTraceFileUrl(traceURL)).then(async response => { const json = JSON.parse(await response.text()); const entries = new Map(); for (const entry of json.entries) @@ -129,14 +129,14 @@ export class FetchTraceModelBackend implements TraceModelBackend { if (!fileName) return; - return fetch(formatUrl(fileName)); + return fetch(formatTraceFileUrl(fileName)); } } const baseURL = new URL(self.location.href); baseURL.port = baseURL.searchParams.get('testServerPort') ?? baseURL.port; -function formatUrl(trace: string) { +function formatTraceFileUrl(trace: string) { if (trace.startsWith('https://www.dropbox.com/')) return 'https://dl.dropboxusercontent.com/' + trace.substring('https://www.dropbox.com/'.length);