mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
21 lines
434 B
JavaScript
21 lines
434 B
JavaScript
import cheerio from 'cheerio'
|
|
const ID_REGEX = /\/profile\/([\w\-.!~*'"(),]+)/g
|
|
|
|
export default function(content) {
|
|
if (!content) return []
|
|
const $ = cheerio.load(content)
|
|
const urls = $('.mention')
|
|
.map((_, el) => {
|
|
return $(el).attr('href')
|
|
})
|
|
.get()
|
|
const ids = []
|
|
urls.forEach(url => {
|
|
let match
|
|
while ((match = ID_REGEX.exec(url)) != null) {
|
|
ids.push(match[1])
|
|
}
|
|
})
|
|
return ids
|
|
}
|