summaryrefslogtreecommitdiff
path: root/internal/uris/uri.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/uris/uri.go')
-rw-r--r--internal/uris/uri.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/uris/uri.go b/internal/uris/uri.go
index ca98b6416..d12e24fea 100644
--- a/internal/uris/uri.go
+++ b/internal/uris/uri.go
@@ -248,6 +248,11 @@ func IsUserPath(id *url.URL) bool {
return regexes.UserPath.MatchString(id.Path)
}
+// IsUserWebPath returns true if the given URL path corresponds to eg /@example_username
+func IsUserWebPath(id *url.URL) bool {
+ return regexes.UserWebPath.MatchString(id.Path)
+}
+
// IsInboxPath returns true if the given URL path corresponds to eg /users/example_username/inbox
func IsInboxPath(id *url.URL) bool {
return regexes.InboxPath.MatchString(id.Path)
@@ -326,6 +331,17 @@ func ParseUserPath(id *url.URL) (username string, err error) {
return
}
+// ParseUserPath returns the username from a path such as /@example_username
+func ParseUserWebPath(id *url.URL) (username string, err error) {
+ matches := regexes.UserWebPath.FindStringSubmatch(id.Path)
+ if len(matches) != 2 {
+ err = fmt.Errorf("expected 2 matches but matches length was %d", len(matches))
+ return
+ }
+ username = matches[1]
+ return
+}
+
// ParseInboxPath returns the username from a path such as /users/example_username/inbox
func ParseInboxPath(id *url.URL) (username string, err error) {
matches := regexes.InboxPath.FindStringSubmatch(id.Path)