A platform for community discussion. Free, open, simple.
PERF: Move URI regexp in `GroupSearchResults.blurb_for` into constant
Guo Xiang Tan4c03a944f65d
diff --git a/lib/search/grouped_search_results.rb b/lib/search/grouped_search_results.rbindex b6059f0ec87..7f22c16f6f6 100644--- a/lib/search/grouped_search_results.rb+++ b/lib/search/grouped_search_results.rb@@ -85,12 +85,14 @@ class Searchendend+ URI_REGEXP = URI.regexp(%w{http https})+def self.blurb_for(cooked: nil, term: nil, blurb_length: BLURB_LENGTH, scrub: true)blurb = nilcooked = SearchIndexer.scrub_html_for_search(cooked) if scruburls = Set.new- cooked.scan(URI.regexp(%w{http https})) { urls << $& }+ cooked.scan(URI_REGEXP) { urls << $& }urls.each do |url|begincase File.extname(URI(url).path || "")