From e3052e8c825da699162ea25367e860ac3c66f461 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:17:10 +0100 Subject: [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 --- internal/regexes/regexes.go | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'internal/regexes') diff --git a/internal/regexes/regexes.go b/internal/regexes/regexes.go index 347a8a98b..25fcfc03a 100644 --- a/internal/regexes/regexes.go +++ b/internal/regexes/regexes.go @@ -57,20 +57,22 @@ const ( Path parts / capture. */ - userPathPrefix = `^/?` + users + `/(` + usernameRelaxed + `)` - userPath = userPathPrefix + `$` - publicKeyPath = userPathPrefix + `/` + publicKey + `$` - inboxPath = userPathPrefix + `/` + inbox + `$` - outboxPath = userPathPrefix + `/` + outbox + `$` - followersPath = userPathPrefix + `/` + followers + `$` - followingPath = userPathPrefix + `/` + following + `$` - likedPath = userPathPrefix + `/` + liked + `$` - followPath = userPathPrefix + `/` + follow + `/(` + ulid + `)$` - likePath = userPathPrefix + `/` + liked + `/(` + ulid + `)$` - statusesPath = userPathPrefix + `/` + statuses + `/(` + ulid + `)$` - blockPath = userPathPrefix + `/` + blocks + `/(` + ulid + `)$` - reportPath = `^/?` + reports + `/(` + ulid + `)$` - filePath = `^/?(` + ulid + `)/([a-z]+)/([a-z]+)/(` + ulid + `)\.([a-z0-9]+)$` + userPathPrefix = `^/?` + users + `/(` + usernameRelaxed + `)` + userPath = userPathPrefix + `$` + userWebPathPrefix = `^/?` + `@(` + usernameRelaxed + `)` + userWebPath = userWebPathPrefix + `$` + publicKeyPath = userPathPrefix + `/` + publicKey + `$` + inboxPath = userPathPrefix + `/` + inbox + `$` + outboxPath = userPathPrefix + `/` + outbox + `$` + followersPath = userPathPrefix + `/` + followers + `$` + followingPath = userPathPrefix + `/` + following + `$` + likedPath = userPathPrefix + `/` + liked + `$` + followPath = userPathPrefix + `/` + follow + `/(` + ulid + `)$` + likePath = userPathPrefix + `/` + liked + `/(` + ulid + `)$` + statusesPath = userPathPrefix + `/` + statuses + `/(` + ulid + `)$` + blockPath = userPathPrefix + `/` + blocks + `/(` + ulid + `)$` + reportPath = `^/?` + reports + `/(` + ulid + `)$` + filePath = `^/?(` + ulid + `)/([a-z]+)/([a-z]+)/(` + ulid + `)\.([a-z0-9]+)$` ) var ( @@ -110,6 +112,9 @@ var ( // UserPath validates and captures the username part from eg /users/example_username. UserPath = regexp.MustCompile(userPath) + // UserWebPath validates and captures the username part from eg /@example_username. + UserWebPath = regexp.MustCompile(userWebPath) + // PublicKeyPath parses a path that validates and captures the username part from eg /users/example_username/main-key PublicKeyPath = regexp.MustCompile(publicKeyPath) -- cgit v1.2.3