mirror of
https://github.com/anatolykopyl/vue-highlights.git
synced 2026-03-29 14:25:07 +00:00
first commit
This commit is contained in:
20
src/utils/extract.js
Normal file
20
src/utils/extract.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user