mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix edge case bug in extractIds
This commit is contained in:
parent
2b03b515e2
commit
2a22aaa907
@ -2,6 +2,7 @@ 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')
|
||||
@ -1,6 +1,12 @@
|
||||
import extractIds from './extractMentions'
|
||||
import extractIds from '.'
|
||||
|
||||
describe('extractIds', () => {
|
||||
describe('content undefined', () => {
|
||||
it('returns empty array', () => {
|
||||
expect(extractIds()).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('extract', () => {
|
||||
describe('searches through links', () => {
|
||||
it('ignores links without .mention class', () => {
|
||||
const content = '<p>Something inspirational about <a href="/profile/u2" target="_blank">@bob-der-baumeister</a> and <a href="/profile/u3" target="_blank">@jenny-rostock</a>.</p>'
|
||||
@ -1,4 +1,4 @@
|
||||
import extractIds from './extractMentions'
|
||||
import extractIds from './extractIds'
|
||||
|
||||
const notify = async (resolve, root, args, context, resolveInfo) => {
|
||||
// extract user ids before xss-middleware removes link classes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user