denoland / website_feedback

For reporting issues & suggestions for deno.com and deno.land
9 stars 1 forks source link

`cdn.deno.land` should serve files with `charset=utf-8` #5

Open kidonng opened 2 years ago

kidonng commented 2 years ago
$ curl -sI https://cdn.deno.land/dayjs/versions/v1.11.3/raw/README.md | grep content-type
content-type: text/markdown
$ # Same file served by GitHub (raw)
$ curl -sI https://raw.githubusercontent.com/iamkun/dayjs/v1.11.3/README.md | grep content-type
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff

$ curl -sI https://cdn.deno.land/dayjs/versions/v1.11.3/raw/src/locale/ja.js | grep content-type
content-type: application/javascript
$ # Same file served by GitHub (raw)
$ curl -sI https://raw.githubusercontent.com/iamkun/dayjs/v1.11.3/src/locale/ja.js | grep content
-type
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff

$ # Static JS/CSS files served by Vercel
$ curl -sI https://static-tweet.vercel.app/_next/static/chunks/webpack-0f6269dce2a0168ec6fb.js | 
grep content-type
content-type: application/javascript; charset=utf-8
$ curl -sI https://static-tweet.vercel.app/_next/static/css/e4d761b45656b197a445.css | grep conte
nt-type
content-type: text/css; charset=utf-8

Notice how cdn.deno.land doesn't serve files with charset=utf-8 in content-type HTTP header while other popular services (GitHub[^1] and Vercel) do.

This is not a serious issue per se, but could potentially lead to garbled text in programs, and (especially) when developers are inspecting the files in the browser directly:

image

[^1]: GitHub raw uses text/plain to discourage hotlinking as raw links are not meant for that.