mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Implement browser update in crawler view (#12448)
browser-update script does not work correctly in some very old browsers because the contents of <noscript> is not accessible in JavaScript. For these browsers, the server can display the crawler page and add the browser update notice. Simply loading the browser-update script in the crawler view is not a solution because that means all crawlers will also see it.
This commit is contained in:
@ -37,6 +37,14 @@ module CrawlerDetection
|
||||
|
||||
end
|
||||
|
||||
def self.show_browser_update?(user_agent)
|
||||
return false if SiteSetting.browser_update_user_agents.blank?
|
||||
|
||||
@browser_update_matchers ||= {}
|
||||
matcher = @browser_update_matchers[SiteSetting.browser_update_user_agents] ||= to_matcher(SiteSetting.browser_update_user_agents)
|
||||
user_agent.match?(matcher)
|
||||
end
|
||||
|
||||
# Given a user_agent that returns true from crawler?, should its request be allowed?
|
||||
def self.allow_crawler?(user_agent)
|
||||
return true if SiteSetting.allowed_crawler_user_agents.blank? &&
|
||||
|
Reference in New Issue
Block a user