handle google url redirect in page crawler

This commit is contained in:
Nazar Kanaev
2022-08-21 13:31:03 +01:00
parent b935a1c511
commit 698f5d6d06
4 changed files with 45 additions and 1 deletions

17
src/content/silo/url.go Normal file
View File

@@ -0,0 +1,17 @@
package silo
import (
"net/url"
"strings"
)
func RedirectURL(link string) string {
if strings.HasPrefix(link, "https://www.google.com/url?") {
if u, err := url.Parse(link); err == nil {
if u2 := u.Query().Get("url"); u2 != "" {
return u2
}
}
}
return link
}