更新 proxy/rewriter.go
This commit is contained in:
@@ -134,10 +134,20 @@ func (r *ContentRewriter) rewriteURL(urlStr string) string {
|
||||
u = r.baseURL.ResolveReference(u)
|
||||
}
|
||||
|
||||
// 保留完整的 URL(包括域名)
|
||||
fullURL := u.String()
|
||||
// 如果是同域名,只保留路径
|
||||
if u.Host == r.baseURL.Host {
|
||||
proxyPath := u.Path
|
||||
if u.RawQuery != "" {
|
||||
proxyPath += "?" + u.RawQuery
|
||||
}
|
||||
if u.Fragment != "" {
|
||||
proxyPath += "#" + u.Fragment
|
||||
}
|
||||
return "/p/" + r.token + proxyPath
|
||||
}
|
||||
|
||||
return "/p/" + r.token + "/" + fullURL
|
||||
// 跨域资源,需要完整 URL
|
||||
return "/p/" + r.token + "/" + u.String()
|
||||
}
|
||||
|
||||
func (r *ContentRewriter) rewriteSrcset(srcset string) string {
|
||||
|
||||
Reference in New Issue
Block a user