Skip to content

Commit

Permalink
Fix *.css.js path (close #728)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Oct 3, 2023
1 parent 47da239 commit 01cfc2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/server_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ func esmHandler() rex.Handle {
if _, ok := targets[maybeTarget]; ok {
submodule := strings.Join(a[1:], "/")
pkgName := strings.TrimSuffix(path.Base(reqPkg.Name), ".js")
if strings.HasSuffix(submodule, ".css") {
if strings.HasSuffix(submodule, ".css") && strings.HasPrefix(reqPkg.Subpath, ".js") {
if submodule == pkgName+".css" {
reqPkg.Submodule = ""
target = maybeTarget
Expand Down
16 changes: 16 additions & 0 deletions test/issue-728/issue-728.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";

Deno.test("issue #728", async () => {
const res = await fetch(
"http://localhost:8080/status.json",
);
const { version } = await res.json();
const res2 = await fetch(
`http://localhost:8080/v${version}/@wooorm/[email protected]/es2022/source.css.js`,
);
res2.body?.cancel();
assertEquals(
res2.headers.get("content-type"),
"application/javascript; charset=utf-8",
);
});

0 comments on commit 01cfc2f

Please sign in to comment.