summaryrefslogtreecommitdiff
path: root/internal/uris/uri.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-01-26 14:17:10 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-26 14:17:10 +0100
commite3052e8c825da699162ea25367e860ac3c66f461 (patch)
tree3d13e83413d4a85ab694034d6c9772f9ec64268a /internal/uris/uri.go
parent[performance] cache library performance enhancements (updates go-structr => v... (diff)
downloadgotosocial-e3052e8c825da699162ea25367e860ac3c66f461.tar.xz
[bugfix] Don't return Account or Status if new and dereferencing failed, other small fixes (#2563)
* tidy up account, status, webfingering logic a wee bit * go fmt * invert published check * alter resp initialization * get Published from account in typeutils * don't instantiate error for no darn good reason * shadow err * don't repeat error codes in wrapped errors * don't wrap error unnecessarily
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)