UBERF-11067: Minor fixes

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artem Savchenko 2025-05-23 13:24:07 +07:00
parent 651dc4eb51
commit 3ceb9c4a0e
3 changed files with 7 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -78,6 +78,10 @@ describe('getMdContent', () => {
// Verify we have the expected guest entries
expect(result).toContain('John Doe')
expect(result).toContain('Sarah Jones')
expect(result).toContain('[Yes](https://example.com/1)')
expect(result).toContain('[No](https://example.com/2)')
expect(result).toContain('[Maybe](https://example.com/3)')
})
it('should handle undefined content gracefully', () => {

View File

@ -33,10 +33,10 @@ export function getMdContent (ctx: MeasureContext, email: EmailMessage): string
const title = element.title ?? ''
// Trim content to prevent empty lines inside links
const trimmedContent = content.trim().replace(/\n\s*\n/g, ' ')
if (!href) {
if (href == null) {
return trimmedContent
}
const titlePart = title ? ` "${title}"` : ''
const titlePart = title !== '' ? ` "${title}"` : ''
return `[${trimmedContent}](${href}${titlePart})`
} catch (error: any) {
ctx.warn('Failed to parse link', { error: error.message })