mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
perf(rewrite): make getPredefinedRewriteRules O(1)
This commit is contained in:
parent
b296f21e98
commit
81df0b2a16
2 changed files with 4 additions and 6 deletions
|
@ -136,11 +136,9 @@ func parseRules(rulesText string) (rules []rule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPredefinedRewriteRules(entryURL string) string {
|
func getPredefinedRewriteRules(entryURL string) string {
|
||||||
urlDomain := urllib.Domain(entryURL)
|
urlDomain := urllib.DomainWithoutWWW(entryURL)
|
||||||
for domain, rules := range predefinedRules {
|
if rules, ok := predefinedRules[urlDomain]; ok {
|
||||||
if strings.Contains(urlDomain, domain) {
|
return rules
|
||||||
return rules
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -26,11 +26,11 @@ var predefinedRules = map[string]string{
|
||||||
"optipess.com": "add_image_title",
|
"optipess.com": "add_image_title",
|
||||||
"peebleslab.com": "add_image_title",
|
"peebleslab.com": "add_image_title",
|
||||||
"quantamagazine.org": `add_youtube_video_from_id, remove("h6:not(.byline,.post__title__kicker), #comments, .next-post__content, .footer__section, figure .outer--content, script")`,
|
"quantamagazine.org": `add_youtube_video_from_id, remove("h6:not(.byline,.post__title__kicker), #comments, .next-post__content, .footer__section, figure .outer--content, script")`,
|
||||||
|
"qwantz.com": "add_image_title,add_mailto_subject",
|
||||||
"sentfromthemoon.com": "add_image_title",
|
"sentfromthemoon.com": "add_image_title",
|
||||||
"thedoghousediaries.com": "add_image_title",
|
"thedoghousediaries.com": "add_image_title",
|
||||||
"theverge.com": `add_dynamic_image, remove("div.duet--recirculation--related-list, .hidden")`,
|
"theverge.com": `add_dynamic_image, remove("div.duet--recirculation--related-list, .hidden")`,
|
||||||
"treelobsters.com": "add_image_title",
|
"treelobsters.com": "add_image_title",
|
||||||
"www.qwantz.com": "add_image_title,add_mailto_subject",
|
|
||||||
"xkcd.com": "add_image_title",
|
"xkcd.com": "add_image_title",
|
||||||
"youtube.com": "add_youtube_video",
|
"youtube.com": "add_youtube_video",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue