mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
20 lines
578 B
TypeScript
20 lines
578 B
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { parseDictionaryExternalUrl } from './dictionary-external-link';
|
|
|
|
test('dictionary links accept web URLs and reject privileged schemes and credentials', () => {
|
|
assert.equal(
|
|
parseDictionaryExternalUrl('https://example.com/word?q=猫'),
|
|
'https://example.com/word?q=%E7%8C%AB',
|
|
);
|
|
for (const value of [
|
|
'file:///etc/passwd',
|
|
'javascript:alert(1)',
|
|
'https://user:pass@example.com',
|
|
null,
|
|
{},
|
|
]) {
|
|
assert.throws(() => parseDictionaryExternalUrl(value));
|
|
}
|
|
});
|