import { describe, expect, it } from 'vitest'; import { PRODUCTION_SITE_URL, resolveSiteUrl } from './siteUrl'; describe('resolveSiteUrl', () => { it('uses the production address without a setting', () => { expect(resolveSiteUrl(undefined)).toBe(PRODUCTION_SITE_URL); expect(resolveSiteUrl('')).toBe(PRODUCTION_SITE_URL); expect(resolveSiteUrl(42)).toBe(PRODUCTION_SITE_URL); }); it.each([ ['https://test.andreaslop.nl', 'https://test.andreaslop.nl'], ['https://test.andreaslop.nl/', 'https://test.andreaslop.nl'], [' https://test.andreaslop.nl ', 'https://test.andreaslop.nl'], ['HTTPS://Test.AndreaSlop.nl', 'https://test.andreaslop.nl'], ['http://localhost:4173', 'http://localhost:4173'], ])('accepts the origin %s', (value, expected) => { expect(resolveSiteUrl(value)).toBe(expected); }); it.each([ 'test.andreaslop.nl', 'http://test.andreaslop.nl', 'ftp://test.andreaslop.nl', 'https://test.andreaslop.nl/pad', 'https://test.andreaslop.nl/?a=1', 'https://test.andreaslop.nl/#x', 'https://gebruiker:wachtwoord@test.andreaslop.nl', 'javascript:alert(1)', ])('falls back to production for %s', (value) => { expect(resolveSiteUrl(value)).toBe(PRODUCTION_SITE_URL); }); });