@vitest/web-worker 0.34.1 → 0.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pure.js +9 -2
- package/package.json +1 -1
package/dist/pure.js
CHANGED
@@ -342,6 +342,13 @@ function getRunnerOptions() {
|
|
342
342
|
state
|
343
343
|
};
|
344
344
|
}
|
345
|
+
function getFileIdFromUrl(url) {
|
346
|
+
if (!(url instanceof URL))
|
347
|
+
url = new URL(url, self.location.origin);
|
348
|
+
if (url.protocol === "http:" || url.protocol === "https:")
|
349
|
+
return url.pathname;
|
350
|
+
return url.toString().replace(/^file:\/+/, "/");
|
351
|
+
}
|
345
352
|
|
346
353
|
function createWorkerConstructor(options) {
|
347
354
|
const runnerOptions = getRunnerOptions();
|
@@ -398,7 +405,7 @@ function createWorkerConstructor(options) {
|
|
398
405
|
(_a = this.onmessageerror) == null ? void 0 : _a.call(this, e);
|
399
406
|
});
|
400
407
|
const runner = new InlineWorkerRunner(runnerOptions, context);
|
401
|
-
const id = (url
|
408
|
+
const id = getFileIdFromUrl(url);
|
402
409
|
this._vw_name = id;
|
403
410
|
runner.resolveUrl(id).then(([, fsPath]) => {
|
404
411
|
this._vw_name = (options2 == null ? void 0 : options2.name) ?? fsPath;
|
@@ -538,7 +545,7 @@ function createSharedWorkerConstructor() {
|
|
538
545
|
(_a = context.onconnect) == null ? void 0 : _a.call(context, e);
|
539
546
|
});
|
540
547
|
const runner = new InlineWorkerRunner(runnerOptions, context);
|
541
|
-
const id = (url
|
548
|
+
const id = getFileIdFromUrl(url);
|
542
549
|
this._vw_name = id;
|
543
550
|
runner.resolveUrl(id).then(([, fsPath]) => {
|
544
551
|
this._vw_name = name ?? fsPath;
|