From e0fc269f77af97f7cf33097d82f92ff7e08a2f06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copla?= =?utf8?q?n?= Date: Fri, 22 Dec 2023 11:38:29 -0800 Subject: [PATCH] net/http: make FileServer look good on mobile MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Ian Lance Taylor Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil Reviewed-by: Max Coplan --- src/net/http/fs.go | 2 ++ src/net/http/fs_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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, "\n") + fmt.Fprintf(w, "\n") fmt.Fprintf(w, "
\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 = "
\n"
+	const dirListPrefix = "\n\n
\n"
 	const dirListSuffix = "\n
\n" tests := []struct { name, escaped string -- 2.48.1