mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(post form): block temporary media links
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user