diff --git a/scripts/pretest.js b/scripts/pretest.js index 8fbf182..ecb3b64 100644 --- a/scripts/pretest.js +++ b/scripts/pretest.js @@ -5,7 +5,7 @@ const modules = [ ]; try { execSync(`rm -rf compiled-tests && mkdir compiled-tests`); - execSync(`npx tsc ${modules.join(' ')} --module commonjs --target es2017 --outDir compiled-tests`, { stdio: 'inherit' }); + execSync(`npx tsc ${modules.join(' ')} --module commonjs --target es2017 --skipLibCheck --outDir compiled-tests`, { stdio: 'inherit' }); } catch (e) { console.error('Failed to compile test modules', e); process.exit(1); diff --git a/tests/urlHelpers.test.js b/tests/urlHelpers.test.js index 1ea5500..a78bfd7 100644 --- a/tests/urlHelpers.test.js +++ b/tests/urlHelpers.test.js @@ -6,6 +6,10 @@ test('removes protocol and trailing slash', () => { assert.strictEqual(normalizeFeedUrl('https://example.com/'), 'example.com'); }); +test('removes protocol regardless of case', () => { + assert.strictEqual(normalizeFeedUrl('HTTP://Example.com'), 'Example.com'); +}); + test('normalizes multiple slashes', () => { assert.strictEqual(normalizeFeedUrl('https://example.com//a//b'), 'example.com/a/b'); }); diff --git a/utils/url-helpers.ts b/utils/url-helpers.ts index ff0ac4b..fdc1a2a 100644 --- a/utils/url-helpers.ts +++ b/utils/url-helpers.ts @@ -4,8 +4,8 @@ export const normalizeFeedUrl = (url: string | null): string => { // First decode to handle any encoded URLs const decoded = decodeURIComponent(url); return decoded - // Remove protocol - .replace(/^https?:\/\//, '') + // Remove protocol (case-insensitive) + .replace(/^https?:\/\//i, '') // Remove trailing slashes .replace(/\/+$/, '') // Normalize multiple slashes @@ -14,4 +14,4 @@ export const normalizeFeedUrl = (url: string | null): string => { console.warn('Error normalizing URL:', error); return url.replace(/\/+$/, ''); } -}; \ No newline at end of file +};