Skip to content

Commit

Permalink
Fix es5-ext weird /#/ path (close #502)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Jan 20, 2023
1 parent 8af32fa commit e454466
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions server/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (task *BuildTask) getImportPath(pkg Pkg, prefix string) string {
if pkg.Submodule != "" {
name = pkg.Submodule
}
// workaround for es5-ext weird "/#/" path
if pkg.Name == "es5-ext" {
name = strings.ReplaceAll(name, "/#/", "/$$/")
}
name = strings.TrimSuffix(name, ".js")
if task.DevMode {
name += ".development"
Expand Down
4 changes: 4 additions & 0 deletions server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ func esmHandler() rex.Handle {
submodule = ""
isPkgCss = true
}
// workaround for es5-ext weird "/#/" path
if pkgName == "es5-ext" {
submodule = strings.ReplaceAll(submodule, "/$$/", "/#/")
}
reqPkg.Submodule = submodule
target = a[0]
isBare = true
Expand Down
4 changes: 3 additions & 1 deletion server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ func identify(importPath string) string {
p := []byte(importPath)
for i, c := range p {
switch c {
case '/', '-', '@', '.':
case '/', '-', '.':
p[i] = '_'
case '@', '#':
p[i] = '$'
default:
p[i] = c
}
Expand Down
7 changes: 7 additions & 0 deletions test/issue-502/issue-502.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";

import d from "http://localhost:8080/[email protected]";

Deno.test("issue #502", () => {
assertEquals(typeof d, "function");
});

0 comments on commit e454466

Please sign in to comment.