Add support for links with no scheme in composer
This commit is contained in:
parent
1df48d4dad
commit
e488cf8f44
4 changed files with 216 additions and 46 deletions
|
@ -77,7 +77,9 @@ function* toSegments(text: string, entities: Entity[]) {
|
|||
let subtext = text.slice(currEnt.index.start, currEnt.index.end)
|
||||
if (
|
||||
!subtext.trim() ||
|
||||
stripUsername(subtext) !== stripUsername(currEnt.value)
|
||||
(currEnt.type === 'mention' &&
|
||||
stripUsername(subtext) !== stripUsername(currEnt.value)) ||
|
||||
(currEnt.type === 'link' && !isSameLink(subtext, currEnt.value))
|
||||
) {
|
||||
// dont yield links to empty strings or strings that don't match the entity value
|
||||
yield subtext
|
||||
|
@ -99,3 +101,9 @@ function* toSegments(text: string, entities: Entity[]) {
|
|||
function stripUsername(v: string): string {
|
||||
return v.trim().replace('@', '')
|
||||
}
|
||||
|
||||
function isSameLink(a: string, b: string) {
|
||||
a = a.startsWith('http') ? a : `https://${a}`
|
||||
b = b.startsWith('http') ? b : `https://${b}`
|
||||
return a === b
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue