DEV: Refactor excluding audio/video URLs from search result blurbs

Followup to 580a4a82
This commit is contained in:
Penar Musaraj
2019-10-31 09:13:24 -04:00
parent c5e67726fd
commit f8b72d9835
3 changed files with 11 additions and 5 deletions

View File

@ -80,8 +80,12 @@ class Search
cooked.scan(URI.regexp(%w{http https})) { urls << $& }
urls.each do |url|
cooked.gsub!(url, I18n.t("search.video")) if url.match(/.(mov|mp4|webm|ogv)/)
cooked.gsub!(url, I18n.t("search.audio")) if url.match(/.(mp3|ogg|wav|m4a)/)
case File.extname(URI(url).path || "")
when Oneboxer::VIDEO_REGEX
cooked.gsub!(url, I18n.t("search.video"))
when Oneboxer::AUDIO_REGEX
cooked.gsub!(url, I18n.t("search.audio"))
end
end
if term