Skip to content

Commit

Permalink
Fix router
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Jan 9, 2025
1 parent 40ff95c commit 81a934d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ func esmRouter() rex.Handle {
if hasTargetSegment {
pathKind = EsmBuild
}
case ".ts", ".mts":
case ".ts", ".mts", ".cts":
if endsWith(pathname, ".d.ts", ".d.mts", ".d.cts") {
pathKind = EsmDts
}
Expand Down Expand Up @@ -1169,10 +1169,12 @@ func esmRouter() rex.Handle {
}()
}
}
if endsWith(esm.SubPath, ".js", ".mjs", ".jsx") {
if endsWith(esm.SubPath, ".js", ".mjs", ".cjs") {
ctx.Header.Set("Content-Type", ctJavaScript)
} else if endsWith(esm.SubPath, ".ts", ".mts", ".tsx") {
} else if endsWith(esm.SubPath, ".ts", ".mts", ".cts", ".tsx") {
ctx.Header.Set("Content-Type", ctTypeScript)
} else if strings.HasSuffix(esm.SubPath, ".jsx") {
ctx.Header.Set("Content-Type", "text/jsx; charset=utf-8")
} else {
contentType := common.ContentType(esm.SubPath)
if contentType != "" {
Expand Down

0 comments on commit 81a934d

Please sign in to comment.