mirror of
https://github.com/taigrr/pastebin
synced 2026-04-13 22:58:03 -07:00
Convert tabs to spaces when displaying
This commit is contained in:
11
server.go
11
server.go
@@ -186,12 +186,15 @@ func (s *Server) ViewHandler() httprouter.Handle {
|
||||
return
|
||||
}
|
||||
|
||||
blob, ok := s.store.Get(uuid)
|
||||
rawBlob, ok := s.store.Get(uuid)
|
||||
if !ok {
|
||||
http.Error(w, "Not Found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
blob := rawBlob.(string)
|
||||
blob = strings.ReplaceAll(blob, "\t", " ")
|
||||
|
||||
switch accepts {
|
||||
case "text/html":
|
||||
s.render(
|
||||
@@ -200,14 +203,14 @@ func (s *Server) ViewHandler() httprouter.Handle {
|
||||
Blob string
|
||||
UUID string
|
||||
}{
|
||||
Blob: blob.(string),
|
||||
Blob: blob,
|
||||
UUID: uuid,
|
||||
},
|
||||
)
|
||||
case "text/plain":
|
||||
w.Write([]byte(blob.(string)))
|
||||
w.Write([]byte(blob))
|
||||
default:
|
||||
w.Write([]byte(blob.(string)))
|
||||
w.Write([]byte(blob))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user