mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:12:25 -05:00
separate public key handler (#64)
This commit is contained in:
parent
82d2544d7d
commit
b6c62309f2
8 changed files with 162 additions and 18 deletions
|
|
@ -60,6 +60,9 @@ var (
|
|||
// userPathRegex parses a path that validates and captures the username part from eg /users/example_username
|
||||
userPathRegex = regexp.MustCompile(userPathRegexString)
|
||||
|
||||
userPublicKeyPathRegexString = fmt.Sprintf(`^?/%s/(%s)/%s`, UsersPath, usernameRegexString, PublicKeyPath)
|
||||
userPublicKeyPathRegex = regexp.MustCompile(userPublicKeyPathRegexString)
|
||||
|
||||
inboxPathRegexString = fmt.Sprintf(`^/?%s/(%s)/%s$`, UsersPath, usernameRegexString, InboxPath)
|
||||
// inboxPathRegex parses a path that validates and captures the username part from eg /users/example_username/inbox
|
||||
inboxPathRegex = regexp.MustCompile(inboxPathRegexString)
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func GenerateURIsForAccount(username string, protocol string, host string) *User
|
|||
followingURI := fmt.Sprintf("%s/%s", userURI, FollowingPath)
|
||||
likedURI := fmt.Sprintf("%s/%s", userURI, LikedPath)
|
||||
collectionURI := fmt.Sprintf("%s/%s/%s", userURI, CollectionsPath, FeaturedPath)
|
||||
publicKeyURI := fmt.Sprintf("%s#%s", userURI, PublicKeyPath)
|
||||
publicKeyURI := fmt.Sprintf("%s/%s", userURI, PublicKeyPath)
|
||||
|
||||
return &UserURIs{
|
||||
HostURL: hostURL,
|
||||
|
|
@ -209,6 +209,11 @@ func IsStatusesPath(id *url.URL) bool {
|
|||
return statusesPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// IsPublicKeyPath returns true if the given URL path corresponds to eg /users/example_username/main-key
|
||||
func IsPublicKeyPath(id *url.URL) bool {
|
||||
return userPublicKeyPathRegex.MatchString(id.Path)
|
||||
}
|
||||
|
||||
// ParseStatusesPath returns the username and ulid from a path such as /users/example_username/statuses/SOME_ULID_OF_A_STATUS
|
||||
func ParseStatusesPath(id *url.URL) (username string, ulid string, err error) {
|
||||
matches := statusesPathRegex.FindStringSubmatch(id.Path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue