Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
break;
case 'message_deleted':
this.collection.deleteMany({ ts: msg.deleted_ts }, (err, res) => {
if(res) {
logger.verbose('Proc', `Message TS ${msg.deleted_ts} removed. Affected row(s): `, res.deletedCount);
}
callback();
});
break;
case 'message_changed':
logger.verbose('Proc', `Message TS ${msg.message.ts} was edited.`);
matches = [];
URI.withinString(msg.message.text, (u) => {
matches.push(u);
return u;
});
if(matches && matches.length > 0) {
logger.verbose('Proc', `Message TS ${msg.message.ts} still is eligible.`);
// Insert or update.
this.collection.findOne({ ts: msg.message.ts })
.then((doc) => {
if(doc) {
// update.
if(doc.text !== msg.message.text) {
logger.verbose('Proc', `Message TS ${msg.message.ts} found on storage. Updating text...`);
doc.text = msg.message.text;
doc.ready = false;
this.collection.replaceOne({ ts: msg.message.ts }, doc, () => {
this.requestPurge(doc);
logs.forEach(msg => {
uri.withinString(msg.value.content.text, (datLink) => {
if (!datLink.startsWith("dat://")) return
// issue #360 in uri.js
var bracket = datLink.indexOf("]")
if (bracket != -1)
datLink = datLink.substring(0, bracket)
var hash = datLink.indexOf("#")
if (hash != -1)
datLink = datLink.substring(0, hash)
var sharePath = shareFolder + "/" + datLink.substring(6)
if (!sharePath.endsWith("/"))
module.exports = (text, limit = 0) => {
const urls = [];
uri.withinString(text, (rawUrl) => {
// Grab a url from upstream
const url = uri(rawUrl).toString();
// Exclusions
if (
// Remove empty matches, http(s)://(/) or www(.)
!url.match(/^(?:http[s]?:\/{1,3}|www[.]?)$/im)
)
// Push result
{ urls.push(url); }
});
return (Number.isInteger(limit) && limit > 0) ? _.take(urls, limit) : urls;
};
run(doc) {
var url = null;
URI.withinString(doc.text, (u) => {
url = url || u;
return u;
});
if(!url) {
return Promise.reject(new Error('Document does not has a valid url'));
} else {
doc.url = url;
return this.runPlugins(doc);
}
}
render: function () {
var text = this.props.description;
var keyIdx = 0;
var idx = 0;
var DescriptionParts = [];
URI.withinString(text, function (url, start, end) {
if (start > idx) {
DescriptionParts.push(span({key: '' + keyIdx++}, text.substr(idx, start)));
}
DescriptionParts.push(a({href: url, target: '_blank', key: '' + keyIdx++}, url));
idx = end;
return url;
});
if (idx < text.length) {
DescriptionParts.push(span({key: '' + keyIdx++}, text.substr(idx)));
}
return span({className: 'help-block'}, DescriptionParts);
}
});
renderUrl(content) {
const h = content
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
const result = URI.withinString(h, function(url) {
let l = url
if (!url.startsWith('http')) {
l = 'https://' + url
}
return `<a rel="noopener noreferrer nofollow" href="${l}">${url}</a>`
})
return result
}
}
u.addHyperlinks = function (text) {
return URI.withinString(text, url => {
const uri = new URI(url);
url = uri.normalize()._string;
const pretty_url = uri._parts.urn ? url : uri.readable();
if (!uri._parts.protocol && !url.startsWith('http://') && !url.startsWith('https://')) {
url = 'http://' + url;
}
if (uri._parts.protocol === 'xmpp' && uri._parts.query === 'join') {
return `<a href="${url}" class="open-chatroom" rel="noopener">${u.escapeHTML(pretty_url)}</a>`;
}
return `<a href="${url}" rel="noopener">${u.escapeHTML(pretty_url)}</a>`;
}, {
'start': /\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi
});
};
render: function () {
var text = this.props.description;
var keyIdx = 0;
var idx = 0;
var DescriptionParts = [];
URI.withinString(text, function (url, start, end) {
if (start > idx) {
DescriptionParts.push(span({key: '' + keyIdx++}, text.substr(idx, start)));
}
DescriptionParts.push(a({href: url, target: '_blank', key: '' + keyIdx++}, url));
idx = end;
return url;
});
if (idx < text.length) {
DescriptionParts.push(span({key: '' + keyIdx++}, text.substr(idx)));
}
return span({className: 'help-block'}, DescriptionParts);
}
});