fish2018/pansou · error
站点地址必须以 http:// 或 https:// 开头
Error message
站点地址必须以 http:// 或 https:// 开头
What it means
normalizeBaseURL requires the site address to carry an http:// or https:// scheme. Although url.Parse succeeded, the parsed scheme is neither http nor https (typically because the input had no scheme and Parse assigned the text to the path component), so the plugin rejects it.
Solutions
- Prefix the address explicitly with https:// (e.g. https://example.com).
- Fix typos like http:/ (single slash) — must be http:// or https://.
- Use only http or https schemes; ftp/file are not supported.
Example fix
// before "site": "http:/example.com" // after "site": "https://example.com"
Defensive patterns
Strategy: validation
Validate before calling
site := strings.TrimSpace(cfg.Site)
if !strings.HasPrefix(site, "http://") && !strings.HasPrefix(site, "https://") {
site = "https://" + site
}
if u, err := url.Parse(site); err != nil || (u.Scheme != "http" && u.Scheme != "https") {
return fmt.Errorf("gying site must start with http:// or https://")
} Try / catch
if err := plugin.Configure(cfg); err != nil {
if strings.Contains(err.Error(), "必须以 http:// 或 https:// 开头") {
return fmt.Errorf("prefix the gying site with https:// in config: %w", err)
}
return err
} Prevention
- Always include the full https:// prefix when writing the config
- Check for single-slash typos like http:/ before saving
- Reject non-http(s) schemes (ftp, file) in your own config validation
- Normalize the URL once at config load time, not at each use
When it happens
Trigger: normalizeBaseURL: url.Parse succeeded but parsed.Scheme != "http" && parsed.Scheme != "https" — e.g. input like 'ftp://host', '//host', or a value where the scheme check prefix test passed but the parsed scheme differs (malformed 'http:/host').
Common situations: Users writing 'example.com' with a single slash typo ('http:/example.com'), or an unsupported scheme like ftp:// or file:// in the config.
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/b22a20390b7b15fd.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/gying/gying.go:609
plugin.RegisterGlobalPlugin(p)
}
func normalizeBaseURL(raw string) (string, error) {
baseURL := strings.TrimSpace(raw)
baseURL = strings.TrimRight(baseURL, "/")
if baseURL == "" {
return "", fmt.Errorf("站点地址不能为空")
}
if !strings.HasPrefix(baseURL, "http://") && !strings.HasPrefix(baseURL, "https://") {
baseURL = "https://" + baseURL
}
parsed, err := url.Parse(baseURL)
if err != nil {
return "", fmt.Errorf("站点地址格式错误: %v", err)
}
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 := hostnameView on GitHub (pinned to beaa561337)