mirror of
https://github.com/anatolykopyl/vue-highlights.git
synced 2026-03-26 21:05:35 +00:00
21 lines
558 B
JavaScript
21 lines
558 B
JavaScript
// Returns an Indexed Array with URL, mention and hashtag
|
|
// entities found in text.
|
|
|
|
import extractMentions from './extractMentions'
|
|
import extractHashtags from './extractHashtags'
|
|
import extractUrls from './extractUrls'
|
|
import removeOverlappingEntities from './removeOverlappingEntities'
|
|
|
|
export default function (text, options) {
|
|
const entities = extractUrls(text, options)
|
|
.concat(extractMentions(text))
|
|
.concat(extractHashtags(text))
|
|
|
|
if (entities.length === 0) {
|
|
return []
|
|
}
|
|
|
|
removeOverlappingEntities(entities)
|
|
return entities
|
|
}
|