Fix some remote posts getting truncated (#27307)

This commit is contained in:
Claire 2023-10-06 12:58:02 +02:00 committed by GitHub
parent e0b54ed3e1
commit 4d59dfb1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -45,6 +45,21 @@ describe('computeHashtagBarForStatus', () => {
);
});
it('does not truncate the contents when the last child is a text node', () => {
const status = createStatus(
'this is a #<a class="zrl" href="https://example.com/search?tag=test">test</a>. Some more text',
['test'],
);
const { hashtagsInBar, statusContentProps } =
computeHashtagBarForStatus(status);
expect(hashtagsInBar).toEqual([]);
expect(statusContentProps.statusContent).toMatchInlineSnapshot(
`"this is a #<a class="zrl" href="https://example.com/search?tag=test">test</a>. Some more text"`,
);
});
it('extract tags from the last line', () => {
const status = createStatus(
'<p>Simple text</p><p><a href="test">#hashtag</a></p>',

View File

@ -109,7 +109,7 @@ export function computeHashtagBarForStatus(status: StatusLike): {
const lastChild = template.content.lastChild;
if (!lastChild) return defaultResult;
if (!lastChild || lastChild.nodeType === Node.TEXT_NODE) return defaultResult;
template.content.removeChild(lastChild);
const contentWithoutLastLine = template;