MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m22s
- /li lists /link first: name prefix, aliases, name, then description - link cards about twice as tall; the bare address below becomes an accent link marker; the link chip bar under bullets is gone, bare web addresses in text are links themselves chore(release): v0.14.3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.6 KiB
TypeScript
32 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { linkCardUrl, hidePreviewContent } from '../linkPreview';
|
|
|
|
describe('link preview helpers', () => {
|
|
it('returns the URL only when the entire trimmed content is a single https address', () => {
|
|
expect(linkCardUrl('https://example.com/a?b=1')).toBe('https://example.com/a?b=1');
|
|
expect(linkCardUrl(' https://example.com/page/ ')).toBe('https://example.com/page/');
|
|
expect(linkCardUrl('Rezept: https://koch.de/spaetzle, lecker!')).toBeNull();
|
|
expect(linkCardUrl('https://a.de https://b.de')).toBeNull();
|
|
expect(linkCardUrl('siehe (https://x.de/p).')).toBeNull();
|
|
expect(linkCardUrl('[Kochseite](https://koch.de)')).toBeNull();
|
|
expect(linkCardUrl('http://unsicher.de')).toBeNull();
|
|
expect(linkCardUrl('nur Text')).toBeNull();
|
|
});
|
|
|
|
it('hides a preview by turning the address into a named link', () => {
|
|
expect(hidePreviewContent('Lesen: https://koch.de/x', 'https://koch.de/x', 'Käsespätzle [Rezept]')).toBe(
|
|
'Lesen: [Käsespätzle Rezept](https://koch.de/x)'
|
|
);
|
|
expect(hidePreviewContent('https://koch.de/x', 'https://koch.de/x', '')).toBe('[koch.de](https://koch.de/x)');
|
|
expect(linkCardUrl(hidePreviewContent('https://koch.de/x', 'https://koch.de/x', 'T'))).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('linkHost', () => {
|
|
it('shows host and path without scheme and www', async () => {
|
|
const { linkHost } = await import('../linkPreview');
|
|
expect(linkHost('https://www.example.com/')).toBe('example.com');
|
|
expect(linkHost('https://example.com/blog/post')).toBe('example.com/blog/post');
|
|
});
|
|
});
|