fish2018/pansou · error

站点域名格式错误

Error message

站点域名格式错误: %v

What it means

Raised at plugin/gying.go:625 after the validator parses the URL and runs idna.Lookup.ToASCII on the hostname. If the hostname cannot be converted to its ASCII (punycode) form — e.g. invalid characters, empty label, or malformed Unicode — the underlying IDNA error is wrapped in this message.

Solutions

  1. Read the wrapped %v detail to identify the IDNA failure (invalid character, empty label, etc.).
  2. Clean the hostname: remove spaces, underscores, and invisible Unicode characters.
  3. For internationalized domains, enter the properly formed Unicode domain or its punycode (xn--) form.
  4. Re-save the plugin config.

Example fix

// before
p.saveConfig("https://exa_mple.com") // invalid host char
// after
p.saveConfig("https://example.com")
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(siteURL)
if err != nil || u.Host == "" { return fmt.Errorf("missing or invalid host") }
if _, err := idna.Lookup.ToASCII(u.Hostname()); err != nil { return fmt.Errorf("hostname not IDNA-valid: %v", err) }

Type guard

func validHostname(raw string) bool {
	u, err := url.Parse(raw)
	if err != nil || u.Host == "" { return false }
	_, err = idna.Lookup.ToASCII(u.Hostname())
	return err == nil
}

Try / catch

baseURL, err := normalizeSiteURL(input)
if err != nil {
	var de *idna.Error
	if errors.As(err, &de) { /* IDNA-specific hint */ }
	return err
}

Prevention

When it happens

Trigger: Configuring a site address whose host contains invalid IDNA characters or malformed Unicode (e.g. underscores in a hostname, stray whitespace, invalid percent-encoding in the host like https://exa%mple.com).

Common situations: Typo or copy/paste artifacts in a non-ASCII domain (e.g. 中文 domains) with an invalid label; hidden zero-width characters from copying a URL from chat or a webpage.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/f2062bfbc0dce867. Report an issue: GitHub.

Appendix: source

Thrown at plugin/gying/gying.go:625

	}
	if parsed.Scheme != "http" && parsed.Scheme != "https" {
		return "", fmt.Errorf("站点地址必须以 http:// 或 https:// 开头")
	}
	if parsed.Host == "" {
		return "", fmt.Errorf("站点地址缺少域名")
	}
	if parsed.RawQuery != "" || parsed.Fragment != "" {
		return "", fmt.Errorf("站点地址不能包含参数或锚点")
	}
	if parsed.Path != "" && parsed.Path != "/" {
		return "", fmt.Errorf("站点地址不能包含路径")
	}

	// HTTP clients do not consistently convert Unicode hostnames to IDNA.
	// Store the ASCII form so both the config page and requests are reliable.
	hostname, err := idna.Lookup.ToASCII(parsed.Hostname())
	if err != nil {
		return "", fmt.Errorf("站点域名格式错误: %v", err)
	}
	host := hostname
	if port := parsed.Port(); port != "" {
		host += ":" + port
	}
	return parsed.Scheme + "://" + host, nil
}

func isLegacyGyingBaseURL(baseURL string) bool {
	parsed, err := url.Parse(baseURL)
	if err != nil {
		return false
	}
	_, ok := legacyGyingHosts[strings.ToLower(strings.TrimSuffix(parsed.Hostname(), "."))]
	return ok
}

func (p *GyingPlugin) configPath() string {

View on GitHub (pinned to beaa561337)