import {test} from 'node:test';import assert from 'node:assert/strict';import {contactLinks} from '../src/contactLinks.mjs'; test('mail aliases produce one safe link per recipient and keep invalid old text visible',()=>{ assert.deepEqual(contactLinks('email_private','a+tag@example.test, b@example.org'),[{label:'a+tag@example.test',href:'mailto:a%2Btag%40example.test'},{label:'b@example.org',href:'mailto:b%40example.org'}]); assert.deepEqual(contactLinks('mail_business','Altwert'),[{label:'Altwert',href:null}]); assert.equal(contactLinks('email','a@example.test\r\nBcc:x@example.org')[0].href,null); }); test('website fields open only absolute HTTP URLs without user information',()=>{ assert.equal(contactLinks('url_business','https://example.test/path?q=x')[0].href,'https://example.test/path?q=x'); for(const value of ['javascript:alert(1)','data:text/html,test','https://user:secret@example.test','https://example.test\r\n/','www.example.test'])assert.equal(contactLinks('url_business',value)[0].href,null); }); test('phone aliases preserve dialable legacy separators without changing exponent-like numbers',()=>{ assert.equal(contactLinks('fax','+49 (30) 123/45')[0].href,'tel:+493012345'); for(const value of ['1e3','Infinity','0x20','kein Telefon'])assert.equal(contactLinks('phone_business',value)[0].href,null); });