repos / pico

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

commit
a872b1d
parent
2efaeed
author
Eric Bower
date
2023-09-06 01:21:04 +0000 UTC
feat(pgs): `{user}.pgs.sh` supported by creating `{user}` project
2 files changed,  +17, -4
M filehandlers/assets/handler.go
+10, -0
 1@@ -23,6 +23,16 @@ type ctxBucketQuotaKey struct{}
 2 type ctxProjectKey struct{}
 3 
 4 func getAssetURL(c *shared.ConfigSite, username, projectName, fpath string) string {
 5+	if username == projectName {
 6+		return fmt.Sprintf(
 7+			"%s://%s.%s/%s",
 8+			c.Protocol,
 9+			username,
10+			c.Domain,
11+			fpath,
12+		)
13+	}
14+
15 	return fmt.Sprintf(
16 		"%s://%s-%s.%s/%s",
17 		c.Protocol,
M pgs/api.go
+7, -4
 1@@ -148,11 +148,14 @@ type SubdomainProps struct {
 2 func getProjectFromSubdomain(subdomain string) (*SubdomainProps, error) {
 3 	props := &SubdomainProps{}
 4 	strs := strings.SplitN(subdomain, "-", 2)
 5-	if len(strs) < 2 {
 6-		return nil, fmt.Errorf("subdomain incorrect format, must have `-` separating username and project: %s", subdomain)
 7-	}
 8 	props.Username = strs[0]
 9-	props.ProjectName = strs[1]
10+
11+	if len(strs) == 2 {
12+		props.ProjectName = strs[1]
13+	} else {
14+		props.ProjectName = props.Username
15+	}
16+
17 	return props, nil
18 }
19