forked from getconversio/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
30 lines (26 loc) · 776 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package goshopify
import (
"fmt"
"strings"
)
// Return the full shop name, including .myshopify.com
func ShopFullName(name string) string {
name = strings.TrimSpace(name)
name = strings.Trim(name, ".")
if strings.Contains(name, "myshopify.com") {
return name
}
return name + ".myshopify.com"
}
// Return the short shop name, excluding .myshopify.com
func ShopShortName(name string) string {
// Convert to fullname and remove the myshopify part. Perhaps not the most
// performant solution, but then we don't have to repeat all the trims here
// :-)
return strings.Replace(ShopFullName(name), ".myshopify.com", "", -1)
}
// Return the Shop's base url.
func ShopBaseUrl(name string) string {
name = ShopFullName(name)
return fmt.Sprintf("https://%s", name)
}