mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 11:35:21 +08:00
http: remove duplicates from listings
This commit is contained in:
parent
28230d93b4
commit
54a2e99d97
|
@ -270,14 +270,20 @@ func parse(base *url.URL, in io.Reader) (names []string, err error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var walk func(*html.Node)
|
||||
var (
|
||||
walk func(*html.Node)
|
||||
seen = make(map[string]struct{})
|
||||
)
|
||||
walk = func(n *html.Node) {
|
||||
if n.Type == html.ElementNode && n.Data == "a" {
|
||||
for _, a := range n.Attr {
|
||||
if a.Key == "href" {
|
||||
name, err := parseName(base, a.Val)
|
||||
if err == nil {
|
||||
names = append(names, name)
|
||||
if _, found := seen[name]; !found {
|
||||
names = append(names, name)
|
||||
seen[name] = struct{}{}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user