fish2018/pansou · error

站点地址不能包含路径

Error message

站点地址不能包含路径

What it means

Thrown by the same URL validator at plugin/gying.go:618 when the parsed site address has a non-empty path (anything other than "/"). The plugin only accepts the site origin; any path suffix means the user entered a deep link rather than the site base.

Solutions

  1. Strip the path so only the origin remains (https://example.com).
  2. If the actual API lives under a subpath, verify the plugin's expected base form; it wants the bare origin only.
  3. Re-save config and reload the plugin.

Example fix

// before
p.saveConfig("https://example.com/forum")
// after
p.saveConfig("https://example.com")
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(siteURL)
if err == nil && u.Path != "" && u.Path != "/" { return fmt.Errorf("strip the path: use %s://%s", u.Scheme, u.Host) }

Type guard

func hasNoPath(raw string) bool {
	u, err := url.Parse(raw)
	return err == nil && (u.Path == "" || u.Path == "/")
}

Try / catch

baseURL, err := normalizeSiteURL(input)
if err != nil {
	return fmt.Errorf("site address rejected: %w", err)
}

Prevention

When it happens

Trigger: Setting the base URL to https://example.com/forum or https://example.com/index.html; pasting a specific page URL from the site into the config.

Common situations: Users copy the URL of a specific forum page or index page instead of the site's root domain when filling in the plugin's site-address setting.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at plugin/gying/gying.go:618

	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 := 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 {

View on GitHub (pinned to beaa561337)