Skip to content

Commit

Permalink
fix(pkg/find/file.go): traverse the hierarchy only through folders
Browse files Browse the repository at this point in the history
Signed-off-by: Massimiliano Giovagnoli <[email protected]>
  • Loading branch information
maxgio92 committed Aug 23, 2023
1 parent 3045bba commit bc63b93
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/find/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package find

import (
"fmt"
"github.com/gocolly/colly"
d "github.com/gocolly/colly/debug"
"github.com/pkg/errors"
"net/url"
"path"
"regexp"
"strings"

"github.com/gocolly/colly"
d "github.com/gocolly/colly/debug"
"github.com/pkg/errors"
)

// crawlFiles returns a list of file names found from the seed URL, filtered by file name regex.
Expand Down Expand Up @@ -81,8 +82,8 @@ func (o *Options) crawlFiles() (*Result, error) {
}
}

// Do not traverse the hierarchy in reverse order.
if o.Recursive && !(strings.Contains(href, UpDir)) && href != RootDir {
// Traverse the folder hierarchy in top-down order.
if o.Recursive && len(folderMatch) > 0 && !(strings.Contains(href, UpDir)) && href != RootDir {
//nolint:errcheck
co.Visit(e.Request.AbsoluteURL(href))
}
Expand Down

0 comments on commit bc63b93

Please sign in to comment.