MCPcopy Index your code
hub / github.com/kopia/kopia / patchIndexBytes

Method patchIndexBytes

internal/server/server.go:750–768  ·  view source on GitHub ↗
(sessionID string, b []byte)

Source from the content-addressed store, hash-verified

748}
749
750func (s *Server) patchIndexBytes(sessionID string, b []byte) []byte {
751 if s.options.UITitlePrefix != "" {
752 b = bytes.ReplaceAll(b, []byte("<title>"), []byte("<title>"+html.EscapeString(s.options.UITitlePrefix)))
753 }
754
755 if v := repo.BuildVersion; v != "" {
756 b = bytes.ReplaceAll(b, []byte(`</title>`), []byte(" v"+html.EscapeString(repo.BuildVersion)+"</title>"))
757 b = bytes.ReplaceAll(b, []byte(`<p class="version-info">Version `), []byte(`<p class="version-info">Version v`+html.EscapeString(repo.BuildVersion+" "+repo.BuildInfo+" ")))
758 }
759
760 csrfToken := s.generateCSRFToken(sessionID)
761
762 // insert <meta name="kopia-csrf-token" content="..." /> just before closing head tag.
763 b = bytes.ReplaceAll(b,
764 []byte(`</head>`),
765 []byte(`<meta name="kopia-csrf-token" content="`+csrfToken+`" /></head>`))
766
767 return b
768}
769
770func maybeReadIndexBytes(fs http.FileSystem) []byte {
771 rootFile, err := fs.Open("index.html")

Callers 1

ServeStaticFilesMethod · 0.95

Calls 1

generateCSRFTokenMethod · 0.95

Tested by

no test coverage detected