更新 proxy/rewriter.go
This commit is contained in:
@@ -43,20 +43,6 @@ func (r *ContentRewriter) RewriteHTML(body []byte) ([]byte, error) {
|
||||
|
||||
func (r *ContentRewriter) rewriteNode(n *html.Node) {
|
||||
if n.Type == html.ElementNode {
|
||||
// 在 head 标签开始处插入 base 标签
|
||||
if n.Data == "head" && n.FirstChild != nil {
|
||||
baseNode := &html.Node{
|
||||
Type: html.ElementNode,
|
||||
Data: "base",
|
||||
Attr: []html.Attribute{
|
||||
{Key: "href", Val: "/p/" + r.token + "/"},
|
||||
},
|
||||
}
|
||||
baseNode.NextSibling = n.FirstChild
|
||||
n.FirstChild.PrevSibling = baseNode
|
||||
baseNode.Parent = n
|
||||
n.FirstChild = baseNode
|
||||
}
|
||||
attrs := map[string]bool{"href": true, "src": true, "action": true, "data": true}
|
||||
|
||||
for i, attr := range n.Attr {
|
||||
|
||||
Reference in New Issue
Block a user