aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorMax πŸ‘¨πŸ½β€πŸ’» Coplan <mchcopl@gmail.com>2023-12-22 11:38:29 -0800
committerGopher Robot <gobot@golang.org>2024-02-24 19:36:28 +0000
commite0fc269f77af97f7cf33097d82f92ff7e08a2f06 (patch)
tree061f17f8c160df23ccc12a35c7b0648dd790fc18 /src/net/http
parentef84d62cfc358ff62c60da9ceec754e7a389b5d5 (diff)
downloadgo-e0fc269f77af97f7cf33097d82f92ff7e08a2f06.tar.xz
net/http: make FileServer look good on mobile
Currently when viewing directories on a phone, the text is small and often hard to tap correctly. This commit adds the viewport property to the page to make it look correct on phones. This commit also makes the page behave in Standards Mode instead of Quirks Mode which does not effect the behavior of this page but makes me feel good inside ☺️ Change-Id: I4babcf79085e85fba57453b7a235e4750a269a42 Reviewed-on: https://go-review.googlesource.com/c/go/+/552595 Auto-Submit: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Max Coplan <mchcopl@gmail.com>
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/fs.go2
-rw-r--r--src/net/http/fs_test.go2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/net/http/fs.go b/src/net/http/fs.go
index af7511a7a4..678b978b7b 100644
--- a/src/net/http/fs.go
+++ b/src/net/http/fs.go
@@ -151,6 +151,8 @@ func dirList(w ResponseWriter, r *Request, f File) {
sort.Slice(dirs, func(i, j int) bool { return dirs.name(i) < dirs.name(j) })
w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ fmt.Fprintf(w, "<!doctype html>\n")
+ fmt.Fprintf(w, "<meta name=\"viewport\" content=\"width=device-width\">\n")
fmt.Fprintf(w, "<pre>\n")
for i, n := 0, dirs.len(); i < n; i++ {
name := dirs.name(i)
diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go
index 861e70caf2..383d27df9b 100644
--- a/src/net/http/fs_test.go
+++ b/src/net/http/fs_test.go
@@ -325,7 +325,7 @@ func TestFileServerCleans(t *testing.T) {
func TestFileServerEscapesNames(t *testing.T) { run(t, testFileServerEscapesNames) }
func testFileServerEscapesNames(t *testing.T, mode testMode) {
- const dirListPrefix = "<pre>\n"
+ const dirListPrefix = "<!doctype html>\n<meta name=\"viewport\" content=\"width=device-width\">\n<pre>\n"
const dirListSuffix = "\n</pre>\n"
tests := []struct {
name, escaped string