{"record":{"id":"b22a20390b7b15fd","repo":"fish2018/pansou","slug":"http-https","errorCode":null,"errorMessage":"站点地址必须以 http:// 或 https:// 开头","messagePattern":"站点地址必须以 http:// 或 https:// 开头","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":609,"sourceCode":"\tplugin.RegisterGlobalPlugin(p)\n}\n\nfunc normalizeBaseURL(raw string) (string, error) {\n\tbaseURL := strings.TrimSpace(raw)\n\tbaseURL = strings.TrimRight(baseURL, \"/\")\n\tif baseURL == \"\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址不能为空\")\n\t}\n\tif !strings.HasPrefix(baseURL, \"http://\") && !strings.HasPrefix(baseURL, \"https://\") {\n\t\tbaseURL = \"https://\" + baseURL\n\t}\n\n\tparsed, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"站点地址格式错误: %v\", err)\n\t}\n\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址必须以 http:// 或 https:// 开头\")\n\t}\n\tif parsed.Host == \"\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址缺少域名\")\n\t}\n\tif parsed.RawQuery != \"\" || parsed.Fragment != \"\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址不能包含参数或锚点\")\n\t}\n\tif parsed.Path != \"\" && parsed.Path != \"/\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址不能包含路径\")\n\t}\n\n\t// HTTP clients do not consistently convert Unicode hostnames to IDNA.\n\t// Store the ASCII form so both the config page and requests are reliable.\n\thostname, err := idna.Lookup.ToASCII(parsed.Hostname())\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"站点域名格式错误: %v\", err)\n\t}\n\thost := hostname","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L591-L627","documentation":"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.","triggerScenarios":"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').","commonSituations":"Users writing 'example.com' with a single slash typo ('http:/example.com'), or an unsupported scheme like ftp:// or file:// in the config.","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."],"exampleFix":"// before\n\"site\": \"http:/example.com\"\n// after\n\"site\": \"https://example.com\"","handlingStrategy":"validation","validationCode":"site := strings.TrimSpace(cfg.Site)\nif !strings.HasPrefix(site, \"http://\") && !strings.HasPrefix(site, \"https://\") {\n    site = \"https://\" + site\n}\nif u, err := url.Parse(site); err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") {\n    return fmt.Errorf(\"gying site must start with http:// or https://\")\n}","typeGuard":null,"tryCatchPattern":"if err := plugin.Configure(cfg); err != nil {\n    if strings.Contains(err.Error(), \"必须以 http:// 或 https:// 开头\") {\n        return fmt.Errorf(\"prefix the gying site with https:// in config: %w\", err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["url","configuration","scheme","go"],"backgroundTag":"invalid-url-format","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}