Closed CptPie closed 3 years ago
With the way it's setup now I can see it becoming a mess of string.Replace()
. We could use a combination of a for loop and a map to make it a bit more maintainable.
Also, there will now be two separate functions that are used to cleanup a link. Why not combine these two into one function?
With that in mind, thoughts?
var replacements map[string]string{
"m.imdb.com": "imdb.com",
}
func linkCleanup(link string) string {
// strip ref
idx := strings.Index(link, "?")
if idx != -1 {
link = link[:idx]
}
// remove mobile
for from, to := range replacements {
link = strings.Replace(link, from, to, 1)
}
return link
}
@zorchenhimer i implemented the requested changes in 99a33fc
This function is used to clean up mobile modifiers in (for now) imdb links. I created the function to later adapt it for more urls (now it just uses strings.Replace). This fixes #91