mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
18 lines
397 B
JavaScript
18 lines
397 B
JavaScript
import cheerio from 'cheerio'
|
|
const ID_REGEX = /\/profile\/([\w\-.!~*'"(),]+)/g
|
|
|
|
export default function (content) {
|
|
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
|
|
}
|