mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Move URI regexp in GroupSearchResults.blurb_for into constant
No need to generate the huge regexp over and over again.
This commit is contained in:
@@ -85,12 +85,14 @@ class Search
|
||||
end
|
||||
end
|
||||
|
||||
URI_REGEXP = URI.regexp(%w{http https})
|
||||
|
||||
def self.blurb_for(cooked: nil, term: nil, blurb_length: BLURB_LENGTH, scrub: true)
|
||||
blurb = nil
|
||||
cooked = SearchIndexer.scrub_html_for_search(cooked) if scrub
|
||||
|
||||
urls = Set.new
|
||||
cooked.scan(URI.regexp(%w{http https})) { urls << $& }
|
||||
cooked.scan(URI_REGEXP) { urls << $& }
|
||||
urls.each do |url|
|
||||
begin
|
||||
case File.extname(URI(url).path || "")
|
||||
|
||||
Reference in New Issue
Block a user