frontend improvement
This commit is contained in:
@@ -141,6 +141,31 @@ describe('useFeeds', () => {
|
|||||||
expect(feeds.value[0].content).not.toContain('<svg')
|
expect(feeds.value[0].content).not.toContain('<svg')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('strips leftover embedded-audio placeholder headings', async () => {
|
||||||
|
feeds.value = [{
|
||||||
|
id: 1,
|
||||||
|
title: 'Article one',
|
||||||
|
url: 'https://www.dw.com/en/article-one/a-1',
|
||||||
|
content: '',
|
||||||
|
}]
|
||||||
|
axios.post.mockResolvedValueOnce({
|
||||||
|
data: {
|
||||||
|
content: `<html><body><article>
|
||||||
|
<h2 aria-label="Eingebetteter Audio-Beitrag — Der Gender Pay Gap existiert noch immer">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill-rule="evenodd"><path d="M14.114 7.599H13.5l.002 4.706h.601l4.582 3.25-.005-11.11zM11.084 4.444l-9.007.002-1.336.797.002 9.514 1.334.793 9.007.006 1.509-.799-.004-9.516z"></path></g></svg>
|
||||||
|
Der Gender Pay Gap existiert noch immer
|
||||||
|
</h2>
|
||||||
|
<p>some article text long enough for readability to keep the paragraph as the main content body, padded with extra words to pass the content-length heuristics used by Mozilla Readability when scoring candidate nodes.</p>
|
||||||
|
</article></body></html>`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
await getReadable(feeds.value[0], 0)
|
||||||
|
|
||||||
|
expect(feeds.value[0].content).not.toContain('Eingebetteter Audio-Beitrag')
|
||||||
|
expect(feeds.value[0].content).not.toContain('<svg')
|
||||||
|
})
|
||||||
|
|
||||||
it('resolves Deutsche-Welle-style templated image URLs from data-format/data-url', async () => {
|
it('resolves Deutsche-Welle-style templated image URLs from data-format/data-url', async () => {
|
||||||
feeds.value = [{
|
feeds.value = [{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
|||||||
@@ -93,11 +93,11 @@ async function getReadable(feed, index) {
|
|||||||
doc.querySelectorAll('img').forEach(resolveTemplatedImage);
|
doc.querySelectorAll('img').forEach(resolveTemplatedImage);
|
||||||
doc.querySelectorAll('video, audio').forEach(el => el.remove());
|
doc.querySelectorAll('video, audio').forEach(el => el.remove());
|
||||||
// Some feeds (e.g. Deutsche Welle) leave behind a heading + play-icon SVG
|
// Some feeds (e.g. Deutsche Welle) leave behind a heading + play-icon SVG
|
||||||
// for an embedded video player whose actual <video>/<iframe> we already
|
// for an embedded video/audio player whose actual <video>/<audio>/<iframe>
|
||||||
// stripped — without it, the heading is just a giant orphaned icon that
|
// we already stripped — without it, the heading is just a giant orphaned
|
||||||
// takes up space and links nowhere.
|
// icon that takes up space and links nowhere.
|
||||||
doc.querySelectorAll('[aria-label]').forEach(el => {
|
doc.querySelectorAll('[aria-label]').forEach(el => {
|
||||||
if (/^(Eingebettetes|Embedded) Video/i.test(el.getAttribute('aria-label'))) {
|
if (/^(Eingebettete[rs]?|Embedded) (Video|Audio)/i.test(el.getAttribute('aria-label'))) {
|
||||||
el.remove()
|
el.remove()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user