mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-01-20 15:22:58 -05:00
24 lines
1020 B
TypeScript
24 lines
1020 B
TypeScript
import { formatInnerLink } from '../../../src/static/js/utils/helpers/formatInnerLink';
|
|
|
|
describe('js/utils/helpers', () => {
|
|
describe('formatInnerLink', () => {
|
|
test('Returns the same absolute URL unchanged', () => {
|
|
const url = 'https://example.com/path?x=1#hash';
|
|
const base = 'https://base.example.org';
|
|
expect(formatInnerLink(url, base)).toBe(url);
|
|
});
|
|
|
|
test('Constructs absolute URL from relative path with leading slash', () => {
|
|
const url = '/images/picture.png';
|
|
const base = 'https://media.example.com';
|
|
expect(formatInnerLink(url, base)).toBe('https://media.example.com/images/picture.png');
|
|
});
|
|
|
|
test('Constructs absolute URL from relative path without leading slash', () => {
|
|
const url = 'assets/file.txt';
|
|
const base = 'https://cdn.example.com';
|
|
expect(formatInnerLink(url, base)).toBe('https://cdn.example.com/assets/file.txt');
|
|
});
|
|
});
|
|
});
|