test(tasks): add unit test for URL basename with trailing slash

Verifies that URLs ending with '/' correctly extract the path segment
as the attachment title without truncation.

Example: https://example.com/projects/ → title: "projects"

This test covers the bug fix in commit 2a8e7433b where the substring
offset was corrected from -2 to -1.
This commit is contained in:
Johannes Millan 2026-01-20 18:58:48 +01:00
parent a910183c10
commit ce615015c9

View file

@ -1534,5 +1534,18 @@ describe('shortSyntax', () => {
expect(r?.attachments.length).toBe(1);
expect(r?.attachments[0].title).toBe('file');
});
it('should extract basename correctly for URLs with trailing slash', () => {
const t = {
...TASK,
title: 'Task https://example.com/projects/',
};
const r = shortSyntax(t, CONFIG);
expect(r).toBeDefined();
expect(r?.attachments.length).toBe(1);
expect(r?.attachments[0].path).toBe('https://example.com/projects/');
expect(r?.attachments[0].title).toBe('projects');
expect(r?.taskChanges.title).toBe('Task');
});
});
});