repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
c96d94b
parent
10b01d4
author
Eric Bower
date
2023-08-04 19:46:31 +0000 UTC
fix: upload url
1 files changed,  +4, -9
M filehandlers/assets/handler.go
+4, -9
 1@@ -4,7 +4,6 @@ import (
 2 	"encoding/binary"
 3 	"fmt"
 4 	"io"
 5-	"net/url"
 6 	"os"
 7 	"path/filepath"
 8 	"strings"
 9@@ -20,17 +19,14 @@ import (
10 
11 type ctxUserKey struct{}
12 
13-func getAssetURL(c *shared.ConfigSite, username, projectName, dir, slug string) string {
14-	fname := url.PathEscape(strings.TrimLeft(slug, "/"))
15-	fdir := strings.TrimLeft(dir, "/")
16+func getAssetURL(c *shared.ConfigSite, username, projectName, fpath string) string {
17 	return fmt.Sprintf(
18-		"%s://%s-%s.%s/%s%s",
19+		"%s://%s-%s.%s/%s",
20 		c.Protocol,
21 		username,
22 		projectName,
23 		c.Domain,
24-		fdir,
25-		fname,
26+		fpath,
27 	)
28 }
29 
30@@ -212,8 +208,7 @@ func (h *UploadAssetHandler) Write(s ssh.Session, entry *utils.FileEntry) (strin
31 		h.Cfg,
32 		user.Name,
33 		projectName,
34-		filepath.Dir(strings.Replace(data.Filepath, projectName, "", 1)),
35-		filepath.Base(data.Filepath),
36+		strings.Replace(data.Filepath, "/"+projectName+"/", "", 1),
37 	)
38 
39 	return url, nil