repos / pico

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

commit
5154fa9
parent
2b52c37
author
Eric Bower
date
2023-03-15 03:32:23 +0000 UTC
feat(prose): aliases can have a leading slash now

It feels more natural to have a leading slash `/` for aliases even
though it's a little more work to handle it properly with current slugs.
1 files changed,  +10, -2
M shared/mdparser.go
+10, -2
 1@@ -110,12 +110,20 @@ func toAliases(obj interface{}) ([]string, error) {
 2 	switch raw := obj.(type) {
 3 	case []interface{}:
 4 		for _, alias := range raw {
 5-			arr = append(arr, alias.(string))
 6+			als := alias.(string)
 7+			if strings.HasPrefix(als, "/") {
 8+				als = als[1:]
 9+			}
10+			arr = append(arr, strings.TrimSpace(als))
11 		}
12 	case string:
13 		aliases := strings.Split(raw, " ")
14 		for _, alias := range aliases {
15-			arr = append(arr, strings.TrimSpace(alias))
16+			als := alias
17+			if strings.HasPrefix(als, "/") {
18+				als = als[1:]
19+			}
20+			arr = append(arr, strings.TrimSpace(als))
21 		}
22 	default:
23 		return arr, fmt.Errorf("unsupported type for `aliases` variable: %T", raw)