Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as twitter from "twitter-text";
const text: string = twitter.htmlEscape("@you #hello < @world > https://github.com");
const entities = twitter.extractEntitiesWithIndices(text);
function isHashtagEntity(e: twitter.EntityWithIndices): e is twitter.HashtagWithIndices {
return "hashtag" in e;
}
function isUrlEntity(e: twitter.EntityWithIndices): e is twitter.UrlWithIndices {
return "url" in e;
}
function isMentionEntity(e: twitter.EntityWithIndices): e is twitter.MentionWithIndices {
return "screenName" in e;
}
function isCashtagEntity(e: twitter.EntityWithIndices): e is twitter.CashtagWithIndices {
return "cashtag" in e;
function insertComment(comment) {
let child = document.createElement('div');
child.className = 'comment-list-item';
child.innerHTML = twitter.autoLink(twitter.htmlEscape(comment.content));
commentList.appendChild(child);
}
getText() {
if (this.props.urlEntity && this.props.urlEntity.display_url) {
return twitterText.linkTextWithEntity(this.props.urlEntity, { invisibleTagAttrs: "style='position:absolute;left:-9999px;'" });
} else {
return twitterText.htmlEscape(this.props.displayUrl);
}
}
getText() {
return '#' + twitterText.htmlEscape(this.props.entity.hashtag);
}
getText() {
return '$' + twitterText.htmlEscape(this.props.entity.cashtag);
}
getText() {
return '@' + twitterText.htmlEscape(this.getIdentifier());
}
getText() {
return twitterText.htmlEscape(this.props.text);
}