mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-31 20:09:11 +00:00
refactor(cuesheet): images are referenced by link only
A path to a local file resolves on the machine running ontime, but not for the clients we serve the cuesheet to, so we no longer accept it. Validation now parses the value as a URL and checks the protocol, which also rejects malformed values that the previous prefix check let through. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CKXcDrZoQXbJpaXiLi1aff
This commit is contained in:
@@ -3,20 +3,22 @@ import { describe, expect, test } from 'vitest';
|
||||
import { isValidImageSource } from '../cuesheet-table/cuesheet-table-elements/EditableImage';
|
||||
|
||||
describe('isValidImageSource()', () => {
|
||||
test('accepts images hosted elsewhere', () => {
|
||||
test('accepts links to a hosted image', () => {
|
||||
expect(isValidImageSource('https://example.com/image.png')).toBe(true);
|
||||
expect(isValidImageSource('http://example.com/image.png')).toBe(true);
|
||||
});
|
||||
|
||||
test('accepts images served by ontime', () => {
|
||||
expect(isValidImageSource('/user/image.png')).toBe(true);
|
||||
expect(isValidImageSource('/external/image.png')).toBe(true);
|
||||
test('rejects references to a local file, they would not resolve for our clients', () => {
|
||||
expect(isValidImageSource('/user/image.png')).toBe(false);
|
||||
expect(isValidImageSource('user/image.png')).toBe(false);
|
||||
expect(isValidImageSource('file:///Users/me/image.png')).toBe(false);
|
||||
expect(isValidImageSource('C:\\images\\image.png')).toBe(false);
|
||||
});
|
||||
|
||||
test('rejects values which would not resolve to an image', () => {
|
||||
expect(isValidImageSource('www.example.com/image.png')).toBe(false);
|
||||
expect(isValidImageSource('example.com/image.png')).toBe(false);
|
||||
expect(isValidImageSource('user/image.png')).toBe(false);
|
||||
expect(isValidImageSource('https://')).toBe(false);
|
||||
expect(isValidImageSource('some text')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user