Replace removed hasIndexes behavior
parent
d83571a59e
commit
4f3bf401da
|
@ -82,13 +82,11 @@ export function extractEntities(
|
||||||
} else if (!match[3].includes('.')) {
|
} else if (!match[3].includes('.')) {
|
||||||
continue // probably not a handle
|
continue // probably not a handle
|
||||||
}
|
}
|
||||||
|
const start = text.indexOf(match[3], match.index) - 1
|
||||||
ents.push({
|
ents.push({
|
||||||
type: 'mention',
|
type: 'mention',
|
||||||
value: match[3],
|
value: match[3],
|
||||||
index: {
|
index: {start, end: start + match[3].length + 1},
|
||||||
start: match.indices[2][0], // skip the (^|\s) but include the '@'
|
|
||||||
end: match.indices[3][1],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,20 +103,16 @@ export function extractEntities(
|
||||||
}
|
}
|
||||||
value = `https://${value}`
|
value = `https://${value}`
|
||||||
}
|
}
|
||||||
const index = {
|
const start = text.indexOf(match[2], match.index)
|
||||||
start: match.indices[2][0], // skip the (^|\s)
|
const index = {start, end: start + match[2].length}
|
||||||
end: match.indices[2][1],
|
// strip ending puncuation
|
||||||
|
if (/[.,;!?]$/.test(value)) {
|
||||||
|
value = value.slice(0, -1)
|
||||||
|
index.end--
|
||||||
}
|
}
|
||||||
{
|
if (/[)]$/.test(value) && !value.includes('(')) {
|
||||||
// strip ending puncuation
|
value = value.slice(0, -1)
|
||||||
if (/[.,;!?]$/.test(value)) {
|
index.end--
|
||||||
value = value.slice(0, -1)
|
|
||||||
index.end--
|
|
||||||
}
|
|
||||||
if (/[)]$/.test(value) && !value.includes('(')) {
|
|
||||||
value = value.slice(0, -1)
|
|
||||||
index.end--
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ents.push({
|
ents.push({
|
||||||
type: 'link',
|
type: 'link',
|
||||||
|
|
Loading…
Reference in New Issue