update: work with webcal

This commit is contained in:
Nathan FONTEYNE 2026-07-23 11:52:09 +02:00
parent 5dce6eb89b
commit fd81b74594
4 changed files with 40 additions and 3 deletions

20
test/icsUrl.test.js Normal file
View file

@ -0,0 +1,20 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { normalizeIcsUrl } = require('../src/lib/icsUrl');
test('normalizeIcsUrl: rewrites webcal:// to https://', () => {
assert.equal(normalizeIcsUrl('webcal://p01-caldav.icloud.com/foo.ics'), 'https://p01-caldav.icloud.com/foo.ics');
});
test('normalizeIcsUrl: rewrites webcals:// to https://', () => {
assert.equal(normalizeIcsUrl('webcals://p01-caldav.icloud.com/foo.ics'), 'https://p01-caldav.icloud.com/foo.ics');
});
test('normalizeIcsUrl: is case-insensitive on the scheme', () => {
assert.equal(normalizeIcsUrl('WebCal://example.com/foo.ics'), 'https://example.com/foo.ics');
});
test('normalizeIcsUrl: leaves http/https URLs untouched', () => {
assert.equal(normalizeIcsUrl('https://example.com/foo.ics'), 'https://example.com/foo.ics');
assert.equal(normalizeIcsUrl('http://example.com/foo.ics'), 'http://example.com/foo.ics');
});