fix(post form): block temporary media links

This commit is contained in:
Tommaso Casaburi
2026-05-16 16:11:22 +07:00
parent 70cf337895
commit a86c523d17
43 changed files with 164 additions and 38 deletions
+10
View File
@@ -10,6 +10,7 @@ vi.mock('../clipboard-utils', () => ({
import {
copyShareLinkToClipboard,
getExpiringMediaLinkHostname,
getHostname,
getPublishURLFilename,
is5chanLink,
@@ -62,6 +63,15 @@ describe('url-utils', () => {
expect(getPublishURLFilename('not-a-url')).toBeNull();
});
it('detects publish media hosts with temporary links', () => {
expect(getExpiringMediaLinkHostname('https://i.4cdn.org/gif/1712345678900.jpg')).toBe('i.4cdn.org');
expect(getExpiringMediaLinkHostname('http://litterbox.catbox.moe/u/example.png')).toBe('litterbox.catbox.moe');
expect(getExpiringMediaLinkHostname('https://www.tmpfiles.org/dl/123/file.mp4')).toBe('tmpfiles.org');
expect(getExpiringMediaLinkHostname('https://cdn.file.kiwi/example')).toBe('file.kiwi');
expect(getExpiringMediaLinkHostname('https://example.com/file.png')).toBeNull();
expect(getExpiringMediaLinkHostname('not-a-url')).toBeNull();
});
it('copies share links for threads and catalog pages using the production fallback base url', async () => {
await copyShareLinkToClipboard('music.eth', 'thread', 'cid-123');
expect(testState.copyToClipboardMock).toHaveBeenCalledWith('https://5chan.app/#/music.eth/thread/cid-123');