DirectLink

By Richard H. Tingstad Last update Jan 24, 2010 — Installed 3,865 times.

Grabs email addresses too

in
Subscribe to Grabs email addresses too 4 posts, 2 voices



ns4tne Scriptwright

The regex used (good job on making that readable, BTW) grabs embedded email address too with the section to allow usernames. I'm not sure this is a good thing, especially since those links come out as e.g. <http://sample_user@hotmail.com/> (from a forum link to MSN Messenger -- <http://members.msn.com/sample_user@hotmail.com>). Now, according to the specs, of course, that's a perfectly well-formed URL -- but in practice, it's VERY unlikely it's actually a URL.

I have two suggestions for correcting this. The first possibility is to try to detect email addresses and give them the right mailto: protocol. The other possibility is to simply discard them.
Personally, I would say a good compromise would be to use a pref to allow discarding emails and default to adding mailto: to appropriate addresses.

 
Richard H. T... Script's Author

Hm, thanks for the comment. It is always a dilemma whether one should handle some cases differently based on probability. I have had similar thoughts regarding the .do extension, but decided to not make any exceptions. The case you mention could be more eligible though.

The question is, how often does this case occur? My guess is that an URL with an email address is not very common. On the other hand, as you say, how often is it an URL with a username?

A third alternative would be to link to both the http: and mailto: versions (if it is a valid email address).

 
Richard H. T... Script's Author

I have now changed the script so that foo@bar.com is treated as an email address. However, I made the http:// interpretation available by interchanging between the two on mouseout.

Email addresses are distinguished from other links by having caption "@".

I hope this works, and that the onmouseout change doesn't confuse too much.

 
ns4tne Scriptwright

The onmouseout change is a bit confusing at first, but for your target audience of power users I don't think it matters much.

At any rate, I greatly appreciate the change.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel