Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static autoBoldText(text, entities) {
if (!entities) return;
twitter.convertUnicodeIndices(text, entities, false);
let result = '';
entities.sort((a, b) =>
a.indices[0] - b.indices[0]
);
let beginIndex = 0;
for (const entity of entities) {
result += text.substring(beginIndex, entity.indices[0]);
if (entity.type) { // Only 'photo' for now (https://dev.twitter.com/overview/api/entities-in-twitter-objects)
result += Color.bold(entity.display_url);
} else if (entity.expanded_url) { // url
result += Color.bold(entity.expanded_url);
} else if (entity.screen_name) { // reply
result += Color.bold('@' + entity.screen_name);
} else if (entity.text) { // hashtag
autoBoldText: function(text, entities) {
twitter.convertUnicodeIndices(text, entities, false);
var result = "";
entities.sort(function(a, b) {
return a.indices[0] - b.indices[0];
});
var beginIndex = 0;
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
result += text.substring(beginIndex, entity.indices[0]);
if (entity.type) { //Only 'photo' for now (https://dev.twitter.com/overview/api/entities-in-twitter-objects)
result += color.bold(entity.display_url);
} else if (entity.expanded_url) { //url
result += color.bold(entity.expanded_url);
} else if (entity.screen_name) { //reply