diff --git a/fetch.go b/fetch.go index 1344028..910848c 100644 --- a/fetch.go +++ b/fetch.go @@ -176,7 +176,16 @@ func isWebAddress(code string) bool { func guessWebScheme(code string) string { host, _, _ := strings.Cut(code, "/") - if strings.HasPrefix(host, "localhost") || strings.HasPrefix(host, "127.0.0.1") { + if strings.HasPrefix(host, "[") { + // ipv6 literal, keep only the bracketed part + if i := strings.Index(host, "]"); i != -1 { + host = host[:i+1] + } + } else if h, _, ok := strings.Cut(host, ":"); ok { + // strip port + host = h + } + if host == "localhost" || host == "127.0.0.1" || host == "[::1]" { return "http://" } return "https://" diff --git a/group.go b/group.go index 26686b9..b621d24 100644 --- a/group.go +++ b/group.go @@ -1029,7 +1029,12 @@ func parseGroupIdentifier(ctx context.Context, c *cli.Command) (relay string, id identifier = ptr.Identifier author = ptr.PublicKey } else if isWebAddress(groupArg) { - webPath, err := nipad.Resolve(ctx, groupArg) + addr := groupArg + if !strings.HasPrefix(addr, "http://") && !strings.HasPrefix(addr, "https://") { + addr = guessWebScheme(addr) + addr + } + + webPath, err := nipad.Resolve(ctx, addr) if err != nil { return "", "", nostr.ZeroPK, fmt.Errorf("failed to resolve group address '%s': %w", groupArg, err) }