From: Max πŸ‘¨πŸ½β€πŸ’» Coplan Date: Fri, 22 Dec 2023 19:38:29 +0000 (-0800) Subject: net/http: make FileServer look good on mobile X-Git-Tag: go1.23rc1~1139 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e0fc269f77af97f7cf33097d82f92ff7e08a2f06;p=gostls13.git 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 Commit-Queue: Ian Lance Taylor Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil Reviewed-by: Max Coplan --- 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