First commit

This commit is contained in:
CyberRex
2026-05-23 17:03:05 +09:00
commit 40e7953ee5
52 changed files with 13004 additions and 0 deletions

21
tests/urlPolicy.test.js Normal file
View File

@@ -0,0 +1,21 @@
import { describe, expect, it } from 'vitest';
import { defaultAliasForUrl, normalizeHttpsUrl } from '../src/server/utils/urlPolicy.js';
describe('urlPolicy', () => {
it('normalizes host-only values to https URLs', () => {
expect(normalizeHttpsUrl('example.com')).toBe('https://example.com/');
});
it('rejects non-https URLs', () => {
expect(() => normalizeHttpsUrl('http://example.com')).toThrow('HTTPS');
});
it('rejects localhost addresses', () => {
expect(() => normalizeHttpsUrl('https://localhost')).toThrow('監視できない');
expect(() => normalizeHttpsUrl('https://127.0.0.1')).toThrow('監視できない');
});
it('uses the hostname as a default alias', () => {
expect(defaultAliasForUrl('https://www.example.com/path')).toBe('www.example.com');
});
});