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('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)')
'(see: <a href="http://www.foo.com">www.foo.com</a>)'
> Ox.parseHTML('foo@bar.com')
@ -73,8 +75,8 @@ Ox.parseHTML = (function() {
},
tab = '\t';
return function(html, tags, wikilinks) {
var matches = [],
tags = tags || defaultTags;
var matches = [];
tags = tags || defaultTags;
// html = Ox.clean(html); fixme: can this be a parameter?
if (tags.indexOf('[]') > -1) {
html = html.replace(/\[(https?:\/\/.+?) (.+?)\]/gi, '<a href="$1">$2</a>');
@ -101,7 +103,7 @@ Ox.parseHTML = (function() {
// close extra opening (and remove extra closing) tags
// note: this converts '&quot;' to '"'
return Ox.element('<div>').html(html).html();
}
};
}());
/*@
@ -153,10 +155,9 @@ Ox.parseURLs = function(html) {
function(str, url, pre, end) {
url = (pre == 'www.' ? 'http://' : '' ) + url;
return Ox.formatString(
'<a href="{url}" title="{url}">{host}</a>{end}',
'<a href="{url}">{url}</a>{end}',
{
end: end,
host: Ox.parseURL(url).hostname,
url: url
}
);