Skip to content

Commit

Permalink
Merge branch 'denislituev/fix_findOnce_panic'
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteSizedMarius committed Feb 16, 2024
2 parents a0eac9d + f8f6d4d commit 5491b93
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions soup.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,12 @@ func matchElementName(n *html.Node, name string) bool {
// Using depth first search to find the first occurrence and return
func findOnce(n *html.Node, args []string, uni bool, strict bool) (*html.Node, bool) {
if n == nil {
if debug {
panic("Pointer node is nil")
}
return nil, false
}

if uni {
if n.Type == html.ElementNode && matchElementName(n, args[0]) {
if len(args) > 1 && len(args) < 4 {
Expand Down Expand Up @@ -523,6 +527,9 @@ func findOnce(n *html.Node, args []string, uni bool, strict bool) (*html.Node, b
// Using depth first search to find all occurrences and return
func findAllofem(n *html.Node, args []string, strict bool) []*html.Node {
if n == nil {
if debug {
panic("Pointer text node is nil")
}
return nil
}
var nodeLinks = make([]*html.Node, 0, 10)
Expand Down

0 comments on commit 5491b93

Please sign in to comment.