forked from 0x2620/oxjs
minor cleanup
This commit is contained in:
parent
b1ff236b3f
commit
e47f826329
4 changed files with 15 additions and 18 deletions
|
|
@ -45,7 +45,6 @@ Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane
|
|||
> Ox.parseHTML('<b>foo</b></b>')
|
||||
'<b>foo</b>'
|
||||
@*/
|
||||
|
||||
Ox.parseHTML = (function() {
|
||||
var defaultTags = [
|
||||
// inline formatting
|
||||
|
|
@ -141,9 +140,9 @@ Ox.parseURL = (function() {
|
|||
var a = document.createElement('a'),
|
||||
keys = ['hash', 'host', 'hostname', 'origin',
|
||||
'pathname', 'port', 'protocol', 'search'];
|
||||
return function(str) {
|
||||
return function(string) {
|
||||
var ret = {};
|
||||
a.href = str;
|
||||
a.href = string;
|
||||
keys.forEach(function(key) {
|
||||
ret[key] = a[key];
|
||||
});
|
||||
|
|
@ -167,14 +166,10 @@ Ox.parseURLs <f> Takes HTML and turns URLs into links
|
|||
Ox.parseURLs = function(html) {
|
||||
return html.replace(
|
||||
/\b((https?:\/\/|www\.).+?)([\.,:;!\?\)\]]*?(\s|$))/gi,
|
||||
function(str, url, pre, end) {
|
||||
url = (pre == 'www.' ? 'http://' : '' ) + url;
|
||||
function(string, url, prefix, end) {
|
||||
url = (prefix == 'www.' ? 'http://' : '') + url;
|
||||
return Ox.formatString(
|
||||
'<a href="{url}">{url}</a>{end}',
|
||||
{
|
||||
end: end,
|
||||
url: url
|
||||
}
|
||||
'<a href="{url}">{url}</a>{end}', {end: end, url: url}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue