diff --git a/app/services/search_indexer.rb b/app/services/search_indexer.rb index 645866db8be..35ccd7a378b 100644 --- a/app/services/search_indexer.rb +++ b/app/services/search_indexer.rb @@ -196,6 +196,11 @@ class SearchIndexer scrubbed << attributes["title"] scrubbed << " " end + if attributes["data-youtube-title"] + scrubbed << " " + scrubbed << attributes["data-youtube-title"] + scrubbed << " " + end end def characters(string) diff --git a/spec/services/search_indexer_spec.rb b/spec/services/search_indexer_spec.rb index fb73ea2fbb4..543d78b9d5b 100644 --- a/spec/services/search_indexer_spec.rb +++ b/spec/services/search_indexer_spec.rb @@ -13,6 +13,14 @@ describe SearchIndexer do expect(raw_data.split(' ').length).to eq(2) end + it 'extract youtube title' do + html = "<div class=\"lazyYT\" data-youtube-id=\"lmFgeFh2nlw\" data-youtube-title=\"Metallica Mixer Explains Missing Bass on 'And Justice for All' [Exclusive]\" data-width=\"480\" data-height=\"270\" data-parameters=\"feature=oembed&wmode=opaque\"></div>" + + scrubbed = SearchIndexer::HtmlScrubber.scrub(html) + + expect(scrubbed).to eq(" Metallica Mixer Explains Missing Bass on 'And Justice for All' [Exclusive] ") + end + it 'correctly indexes a post according to version' do # Preparing so that they can be indexed to right version SearchIndexer.update_posts_index(post_id, "dummy", "", nil, nil)