First commit
This commit is contained in:
21
tests/urlPolicy.test.js
Normal file
21
tests/urlPolicy.test.js
Normal 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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user