do not shorten urls, just turn them into links

This commit is contained in:
j 2012-02-10 15:22:09 +05:30
parent 600dc935f2
commit 21854f653e

View file

@ -15,7 +15,9 @@ Ox.parseEmailAddresses = function(html) {
/*@ /*@
Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane
> Ox.parseHTML('http://foo.com, bar') > Ox.parseHTML('http://foo.com, bar')
'<a href="http://foo.com">foo.com</a>, bar' '<a href="http://foo.com">http://foo.com</a>, bar'
> Ox.parseHTML('http://foo.com/foobar?foo, bar')
'<a href="http://foo.com/foobar?foo">http://foo.com/foobar?foo</a>, bar'
> Ox.parseHTML('(see: www.foo.com)') > Ox.parseHTML('(see: www.foo.com)')
'(see: <a href="http://www.foo.com">www.foo.com</a>)' '(see: <a href="http://www.foo.com">www.foo.com</a>)'
> Ox.parseHTML('foo@bar.com') > Ox.parseHTML('foo@bar.com')
@ -73,7 +75,7 @@ Ox.parseHTML = (function() {
}, },
tab = '\t'; tab = '\t';
return function(html, tags, wikilinks) { return function(html, tags, wikilinks) {
var matches = [], var matches = [];
tags = tags || defaultTags; tags = tags || defaultTags;
// html = Ox.clean(html); fixme: can this be a parameter? // html = Ox.clean(html); fixme: can this be a parameter?
if (tags.indexOf('[]') > -1) { if (tags.indexOf('[]') > -1) {
@ -101,7 +103,7 @@ Ox.parseHTML = (function() {
// close extra opening (and remove extra closing) tags // close extra opening (and remove extra closing) tags
// note: this converts '&quot;' to '"' // note: this converts '&quot;' to '"'
return Ox.element('<div>').html(html).html(); return Ox.element('<div>').html(html).html();
} };
}()); }());
/*@ /*@
@ -153,10 +155,9 @@ Ox.parseURLs = function(html) {
function(str, url, pre, end) { function(str, url, pre, end) {
url = (pre == 'www.' ? 'http://' : '' ) + url; url = (pre == 'www.' ? 'http://' : '' ) + url;
return Ox.formatString( return Ox.formatString(
'<a href="{url}" title="{url}">{host}</a>{end}', '<a href="{url}">{url}</a>{end}',
{ {
end: end, end: end,
host: Ox.parseURL(url).hostname,
url: url url: url
} }
); );