Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
chunks.unshift(chunk)
break
}
}
if (chunks.length == 0) { // only has mentions???
mentions = chunks
mentions = []
mentionsLength = 0
} else if (mentionsLength > 140) {
e.sender.send('surfbird:hook:fail:tweet')
return console.error('Too many mentions!')
}
// map urls
var urls = twittxt.extractUrls(tweet.text, {extractUrlsWithoutProtocol: false}).map(function (it) {
return it.toLowerCase()
})
while (chunks.length > 0) {
var tweet = [].concat(mentions)
var textLength = 0
while (tweet.length + textLength + mentionsLength - 1 < 140 && chunks.length > 0) {
var chunk = chunks.shift()
var length = chunk.length
// check if it's a url
if (urls.indexOf(chunk.toLowerCase()) > -1) {
length = chunk.match(twittxt.regexen.urlHasHttps) ? 23 : 23 // TODO: Use configuration.
}
// chunk if overflow
if (tweet.length + textLength + mentionsLength + length > 140) {
// word is too long, split it up.
function parseUrlForIndexer(query) {
const query_trim = query.trim();
if (query_trim.length <= 2) return;
const urls = twitter.extractUrls(query_trim);
if (urls.length === 0) return;
const url = lo_first(urls);
const ratio = url.length / query_trim.length;
if (ratio <= 0.9) return;
return {
id: url,
primaryText: url,
secondaryText: url,
group: 'Link'
};
}
this.typeTimeout = setTimeout(this.typeTimeoutFn, 1000);
}
if (e.key === "Enter") {
e.preventDefault();
this.typing = false;
clearTimeout(this.typeTimeout);
this.channel.push("new_typing", {uuid: this.props.userReducer.uuid, typing: false});
if(e.target.value.length > 0 ) {
if (e.target.value[0] === '#' && !e.target.value.includes(" ")) {
return this.processTagFromInput(e);
}
const message = e.target.value;
let allTags = this.state.tags.slice(0,1);
const urls = this.props.userReducer.urlPreviews ? twitter.extractUrls(message).map((url) => url.startsWith('http') ? url : 'https://' + url) : [];
const extractedTags = twitter.extractHashtags(message);
extractedTags.forEach((extractedTag) => {
const downcaseTag = extractedTag.toLowerCase();
allTags = allTags.includes(downcaseTag) ? allTags : [
...allTags,
downcaseTag
]
})
this.pubKeyObj = this.pubKeyObj || openpgp.key.readArmored(this.props.cryptoReducer.groups[this.room].publicKey).keys
const options = {
data: message,
publicKeys: this.pubKeyObj,
armored: false
};
UrlTokenizer.prototype.tokenize = function (s) {
if (!s || s.length == 0)
return [];
if (this.includeIndices) {
return twitter.extractUrlsWithIndices(s);
}
else {
return twitter.extractUrls(s);
}
};