@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.
Files changed (2) hide show
  1. package/dist/pure.js +9 -2
  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 instanceof URL ? url.toString() : url).replace(/^file:\/+/, "/");
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 instanceof URL ? url.toString() : url).replace(/^file:\/+/, "/");
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/web-worker",
3
3
  "type": "module",
4
- "version": "0.34.1",
4
+ "version": "0.34.2",
5
5
  "description": "Web Worker support for testing in Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",