ts-arc 1.3.1 → 1.3.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/loader.js +8 -7
  2. package/package.json +1 -1
package/dist/loader.js CHANGED
@@ -320,11 +320,11 @@ async function resolve2(specifier, context, nextResolve) {
320
320
  if (!real) {
321
321
  throw new Error("Copycat file URI is missing the `real` searchparam.");
322
322
  }
323
- const realPath = path.resolve(real);
324
- const out = new URL(specifier);
325
- out.pathname = realPath;
326
- out.searchParams.set("real", realPath);
323
+ const pretendPath = path.resolve(u.pathname);
324
+ const fileUrl = url.pathToFileURL(pretendPath).href;
325
+ const out = new URL(fileUrl);
327
326
  out.searchParams.set("copycat", "true");
327
+ out.searchParams.set("real", real);
328
328
  return {
329
329
  url: out.href,
330
330
  shortCircuit: true
@@ -391,11 +391,12 @@ async function load(urlStr, context, nextLoad) {
391
391
  function loadSync(urlStr, context, nextLoadSync) {
392
392
  const u = new URL(urlStr);
393
393
  if (u.searchParams.has("copycat")) {
394
- const real = u.searchParams.get("real");
395
- if (!real) {
394
+ const realEncoded = u.searchParams.get("real");
395
+ if (!realEncoded) {
396
396
  throw new Error("Copycat file URI is missing the `real` searchparam.");
397
397
  }
398
- const code = fs.readFileSync(decodeURI(real), "utf8");
398
+ const realPath = decodeURIComponent(realEncoded);
399
+ const code = fs.readFileSync(realPath, "utf8");
399
400
  return {
400
401
  format: "module",
401
402
  source: code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",