(x string, domain string)
| 1282 | } |
| 1283 | |
| 1284 | func addDomain(x string, domain string) string { |
| 1285 | if strings.HasPrefix(x, "#") || strings.HasPrefix(x, "mailto:") || strings.HasPrefix(x, "tel:") || strings.HasPrefix(x, "data:") || strings.HasPrefix(x, "javascript:") || (strings.Contains(x, "://") && !strings.HasPrefix(x, "http")) { // we only want http,https,// or relative |
| 1286 | return "" |
| 1287 | } |
| 1288 | x = strings.SplitN(x, "#", 2)[0] // remove everything after # (anchor) |
| 1289 | if strings.HasPrefix(x, "https://"+domain) || strings.HasPrefix(x, "http://"+domain) { |
| 1290 | return x |
| 1291 | } else if strings.HasPrefix(x, "//"+domain) { |
| 1292 | return Config.Website.Url.Scheme + ":" + x // add the scheme to the url |
| 1293 | } else if !strings.HasPrefix(x, "http://") && !strings.HasPrefix(x, "https://") && !strings.HasPrefix(x, "//") { |
| 1294 | if strings.HasPrefix(x, "/") { |
| 1295 | return Config.Website.Domain + x |
| 1296 | } else { // we need to add the basepath to the relative path |
| 1297 | basePath := path.Dir(Config.Website.Url.Path) |
| 1298 | return Config.Website.Domain + strings.TrimSuffix(basePath, "/") + "/" + strings.TrimPrefix(x, "/") |
| 1299 | } |
| 1300 | } else { |
| 1301 | for i, d := range Config.RecDomains { |
| 1302 | if Config.RecDomains[i] == "" { |
| 1303 | continue |
| 1304 | } |
| 1305 | if strings.HasPrefix(x, "https://"+d) || strings.HasPrefix(x, "http://"+d) { |
| 1306 | return x |
| 1307 | } |
| 1308 | if strings.HasPrefix(x, "//"+d) { |
| 1309 | return Config.Website.Url.Scheme + ":" + x // add the scheme to the url |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | msg := fmt.Sprintf("%s doesn't have %s as domain\n", x, domain) |
| 1314 | PrintVerbose(msg, NoColor, 2) |
| 1315 | |
| 1316 | return "" |
| 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | func checkRecInclude(x string, recInclude string) bool { |
| 1321 | for _, inc := range strings.Split(recInclude, " ") { |
no test coverage detected