@@ -73,24 +73,28 @@ func prepareFilter(tags []string) links.TokenFilter {
73
73
74
74
func canCrawl (a , b * url.URL , d int , subdomains bool ) (yes bool ) {
75
75
if a .Host != b .Host {
76
- if subdomains {
77
- domainA := strings .Split (a .Host , "." )
78
- domainB := strings .Split (b .Host , "." )
79
- if len (domainA ) >= len (domainB ){
80
- // The base domain must be shorter than the found domain
81
- return
82
- }
83
- j := len (domainB ) - 1
84
- for i := len (domainA ) - 1 ; i >= 0 && j >= 0 ; i -- {
85
- // Traverse each domain from the end, to check if their top-level domain are the same
86
- if domainA [i ] != domainB [j ] {
87
- // not the same top-level host
88
- return
89
- }
90
- j --
76
+ if ! subdomains {
77
+ return false
78
+ }
79
+
80
+ domainA := strings .Split (a .Host , "." )
81
+ domainB := strings .Split (b .Host , "." )
82
+
83
+ if len (domainA ) >= len (domainB ) {
84
+ // The base domain must be shorter than the found domain
85
+ return false
86
+ }
87
+
88
+ j := len (domainB ) - 1
89
+
90
+ for i := len (domainA ) - 1 ; i >= 0 && j >= 0 ; i -- {
91
+ // Traverse each domain from the end, to check if their top-level domain are the same
92
+ if domainA [i ] != domainB [j ] {
93
+ // not the same top-level host
94
+ return false
91
95
}
92
- } else {
93
- return
96
+
97
+ j --
94
98
}
95
99
}
96
100
@@ -106,11 +110,11 @@ func canCrawl(a, b *url.URL, d int, subdomains bool) (yes bool) {
106
110
107
111
depth , found := relativeDepth (apath , bpath )
108
112
if ! found {
109
- return
113
+ return false
110
114
}
111
115
112
116
if d >= 0 && depth > d {
113
- return
117
+ return false
114
118
}
115
119
116
120
return true
0 commit comments