From d3b791d516e9160d4fc63baf6d08d160b7ed54e8 Mon Sep 17 00:00:00 2001 From: Adam Pash Date: Thu, 1 Sep 2016 13:45:00 -0400 Subject: [PATCH] fix: title wasn't cleaning html tags --- src/extractor/generic/title/utils/clean-title.js | 3 ++- src/extractor/generic/title/utils/clean-title.test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extractor/generic/title/utils/clean-title.js b/src/extractor/generic/title/utils/clean-title.js index da59603d..12ee82af 100644 --- a/src/extractor/generic/title/utils/clean-title.js +++ b/src/extractor/generic/title/utils/clean-title.js @@ -18,5 +18,6 @@ export default function cleanTitle(title, url, $) { } } - return title.trim() + // strip any html tags in the title text + return stripTags(title, $).trim() } diff --git a/src/extractor/generic/title/utils/clean-title.test.js b/src/extractor/generic/title/utils/clean-title.test.js index 7ff320c6..604ebaa1 100644 --- a/src/extractor/generic/title/utils/clean-title.test.js +++ b/src/extractor/generic/title/utils/clean-title.test.js @@ -20,8 +20,8 @@ describe('cleanTitle(title, $)', () => { }) it('removes HTML tags from titles', () => { - const title = "Too Short" const $ = cheerio.load(HTML.docWithTagsInH1.before) + const title = $('h1').html() assert.equal(cleanTitle(title, '', $), HTML.docWithTagsInH1.after) })