summaryrefslogtreecommitdiff
path: root/internal/util/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/util/parse.go')
-rw-r--r--internal/util/parse.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/util/parse.go b/internal/util/parse.go
new file mode 100644
index 000000000..375ab97f2
--- /dev/null
+++ b/internal/util/parse.go
@@ -0,0 +1,32 @@
+package util
+
+import "fmt"
+
+type URIs struct {
+ HostURL string
+ UserURL string
+ UserURI string
+ InboxURL string
+ OutboxURL string
+ FollowersURL string
+ CollectionURL string
+}
+
+func GenerateURIs(username string, protocol string, host string) *URIs {
+ hostURL := fmt.Sprintf("%s://%s", protocol, host)
+ userURL := fmt.Sprintf("%s/@%s", hostURL, username)
+ userURI := fmt.Sprintf("%s/users/%s", hostURL, username)
+ inboxURL := fmt.Sprintf("%s/inbox", userURI)
+ outboxURL := fmt.Sprintf("%s/outbox", userURI)
+ followersURL := fmt.Sprintf("%s/followers", userURI)
+ collectionURL := fmt.Sprintf("%s/collections/featured", userURI)
+ return &URIs{
+ HostURL: hostURL,
+ UserURL: userURL,
+ UserURI: userURI,
+ InboxURL: inboxURL,
+ OutboxURL: outboxURL,
+ FollowersURL: followersURL,
+ CollectionURL: collectionURL,
+ }
+}