File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,16 +22,25 @@ type DiscogsScraper struct {
2222}
2323
2424// NewDiscogsScraper 创建Discogs刮削器
25- // baseURL 为可自定义的 Discogs API 服务地址,为空时使用默认 https://api.discogs.com
25+ //
26+ // 用户只需填写「域名 + API 前缀」,例如:
27+ // 1. 留空:使用默认 https://api.discogs.com
28+ // 2. 官方:api.discogs.com -> https://api.discogs.com
29+ // 3. 反代:example.edgeone.run/api/discogs -> https://example.edgeone.run/api/discogs
30+ // 4. 反代:example.edgeone.run/api/discogs/ -> https://example.edgeone.run/api/discogs(自动去尾斜杠)
31+ //
32+ // 后续会基于 BaseURL 直接拼接 /database/search、/releases/{id} 等具体路径。
2633func NewDiscogsScraper (token string , baseURL string ) * DiscogsScraper {
2734 base := strings .TrimRight (strings .TrimSpace (baseURL ), "/" )
2835 if base == "" {
2936 base = discogsDefaultBaseURL
3037 }
31- // 若用户填入的地址未带协议头,则自动补全为 https://
38+ // 协议头容错:用户没填 http/https 时自动补 https://
3239 if ! strings .HasPrefix (base , "http://" ) && ! strings .HasPrefix (base , "https://" ) {
3340 base = "https://" + base
3441 }
42+ // 再次去掉末尾多余的 /,避免后续拼接出 //database/search 这类双斜杠
43+ base = strings .TrimRight (base , "/" )
3544 return & DiscogsScraper {
3645 Token : token ,
3746 BaseURL : base ,
You can’t perform that action at this time.
0 commit comments