style: using effective go and refactoring

This commit is contained in:
Kay
2023-08-21 20:17:25 +08:00
committed by fiatjaf_
parent abb66db97e
commit ac2350c722
17 changed files with 81 additions and 68 deletions

View File

@@ -23,8 +23,8 @@ func CreateUnsignedAuthEvent(challenge, pubkey, relayURL string) nostr.Event {
}
}
// helper function for ValidateAuthEvent
func parseUrl(input string) (*url.URL, error) {
// helper function for ValidateAuthEvent.
func parseURL(input string) (*url.URL, error) {
return url.Parse(
strings.ToLower(
strings.TrimSuffix(input, "/"),
@@ -43,12 +43,12 @@ func ValidateAuthEvent(event *nostr.Event, challenge string, relayURL string) (p
return "", false
}
expected, err := parseUrl(relayURL)
expected, err := parseURL(relayURL)
if err != nil {
return "", false
}
found, err := parseUrl(event.Tags.GetFirst([]string{"relay", ""}).Value())
found, err := parseURL(event.Tags.GetFirst([]string{"relay", ""}).Value())
if err != nil {
return "", false
}