Let pages in the page view load their local files
This commit is contained in:
@@ -226,16 +226,12 @@ func serveFile(w http.ResponseWriter, root, rel string) {
|
||||
writeJSON(w, http.StatusOK, fc)
|
||||
}
|
||||
|
||||
func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID string, params api.GetTaskRawParams) {
|
||||
t, ok := s.activeTask(w, r, taskID)
|
||||
if !ok {
|
||||
func (s *Server) GetRaw(w http.ResponseWriter, r *http.Request, params api.GetRawParams) {
|
||||
full := filepath.Clean(filepath.FromSlash(params.Path))
|
||||
if !filepath.IsAbs(full) {
|
||||
writeError(w, http.StatusBadRequest, errors.New("path must be absolute"))
|
||||
return
|
||||
}
|
||||
if params.Path == "" {
|
||||
writeError(w, http.StatusBadRequest, errors.New("path is required"))
|
||||
return
|
||||
}
|
||||
name, full := taskPath(t.WorktreePath, params.Path)
|
||||
|
||||
f, err := os.Open(full)
|
||||
if err != nil {
|
||||
@@ -254,7 +250,7 @@ func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID strin
|
||||
return
|
||||
}
|
||||
|
||||
contentType := mime.TypeByExtension(path.Ext(name))
|
||||
contentType := mime.TypeByExtension(filepath.Ext(full))
|
||||
if contentType == "" {
|
||||
contentType = "application/octet-stream"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user