card view, minor css bugfixes
This commit is contained in:
@@ -118,6 +118,34 @@ describe('useFeeds', () => {
|
||||
expect(feeds.value[0].content).not.toMatch(/src="[^"]*(\$\{|%7[bB])/)
|
||||
})
|
||||
|
||||
it('resolves templated images regardless of the placeholder name and scrubs other lazy-load attributes', 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>
|
||||
<img data-format="MASTER_LANDSCAPE" data-id="76212061"
|
||||
data-url="https://static.dw.com/image/76212061_\${size}.jpg"
|
||||
data-src="https://static.dw.com/image/76212061_\${size}.jpg"
|
||||
alt="Merz and Trump" src="data:image/gif;base64,placeholder">
|
||||
<p>some article text long enough for readability to keep the image and paragraph together in the parsed output, padded with extra words to pass the content-length heuristics used by Mozilla Readability when scoring candidate nodes for the main article body.</p>
|
||||
</article></body></html>`,
|
||||
},
|
||||
})
|
||||
|
||||
await getReadable(feeds.value[0], 0)
|
||||
|
||||
// `${size}` isn't the hardcoded `${formatId}` placeholder, but `data-format`
|
||||
// is still the right substitution — and lazy-load attributes like `data-src`
|
||||
// (which Readability may promote into `src`) must be cleaned too, not just
|
||||
// `data-url`, so a stale template can't resurface in the rendered output.
|
||||
expect(feeds.value[0].content).not.toMatch(/src="[^"]*(\$\{|%7[bB])/)
|
||||
})
|
||||
|
||||
it('drops unresolvable templated images instead of leaving a broken src', async () => {
|
||||
feeds.value = [{
|
||||
id: 1,
|
||||
|
||||
Reference in New Issue
Block a user