deno-udd icon indicating copy to clipboard operation
deno-udd copied to clipboard

Extra suffix slash

Open Xeevis opened this issue 3 years ago • 3 comments

When updating module from esm.sh

import confetti from "https://esm.sh/[email protected]";

UDD turns it into

import confetti from "https://esm.sh/[email protected]/";

It's a convention to not include extra slash and it's not just cosmetic, it actually invalidates the cache, as Deno will keep separate copies for both [email protected] and [email protected]/

image

Xeevis avatar Jan 23 '22 15:01 Xeevis

cc @takker99 .

Is this the case for all "scoped" urls?

hayd avatar Jan 23 '22 17:01 hayd

I see in tests that suffix slash is always created for paths that don't end with extension. There shouldn't be any assumptions about the final string, only the version portion from original string needs to be changed (applies to all registries). For example this test needs to pass, but currently doesn't and even output may be different than expected because of missing pin (esm.sh engine version).

Deno.test("registryEsmShPinned", () => {
  const url = "https://esm.sh/[email protected]?pin=63";
  const v = lookup(url, REGISTRIES);
  assert(v !== undefined);

  const vAt = v.at("0.2.0");
  assertEquals(vAt.url, "https://esm.sh/[email protected]?pin=63");
});
    [Diff] Actual / Expected

-   "https://esm.sh/[email protected]/"
+   "https://esm.sh/[email protected]?pin=63"

Xeevis avatar Jan 25 '22 08:01 Xeevis

@hayd any update on this? A slash is still being added, which results in errors.

{
  "imports": {
    "twind": "https://esm.sh/[email protected]",
    "twind/": "https://esm.sh/[email protected]/"
    // after
    "twind": "https://esm.sh/[email protected]/",
    "twind/": "https://esm.sh/[email protected]//"
  }
}

omar2205 avatar Aug 26 '22 22:08 omar2205