Skip to content
Snippets Groups Projects
Commit 559210b8 authored by rswindell's avatar rswindell
Browse files

Added new function fidoaddr_to_emailaddr() which takes a message's From

name (e.g. "Rob Swindell") and fidonet source address (e.g. "1:103/705")
and converts it to an Internet email compatible address format
(e.g. "Rob.Swindell@f705.n103.z1.fidonet") - for use with the listserver.js
parent 688ac467
No related branches found
No related tags found
No related merge requests found
......@@ -27,4 +27,32 @@ function mail_get_address(strIn) {
if (strIn.match(reEmail1)) return strIn.replace(reEmail1,"$1");
if (strIn.match(reEmail2)) return strIn.replace(reEmail2,"$1");
return null;
}
\ No newline at end of file
}
function fidoaddr_to_emailaddr(name, addr, tld)
{
var ftn;
// Change "Joe Ray Schmoe" to "Joe.Ray.Schmoe"
name = name.replace(/\ /g, '.');
// If no top-level-domain specified, use "fidonet" by default
if(!tld) tld = "fidonet";
// FTN domain specified?
ftn = addr.match(/@([\w]+)$/);
if(ftn)
tld = ftn[1];
// Look for 4D addr
ftn = addr.match(/^([0-9]+)\:([0-9]+)\/([0-9]+)\.([0-9]+)/);
if(ftn)
return format("%s@p%u.f%u.n%u.z%u.%s", name, ftn[4], ftn[3], ftn[2], ftn[1], tld);
// Look for 3D addr
ftn = addr.match(/^([0-9]+)\:([0-9]+)\/([0-9]+)/);
if(ftn)
return format("%s@f%u.n%u.z%u.%s", name, ftn[3], ftn[2], ftn[1], tld);
return addr;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment