mirror of
https://github.com/usememos/memos.git
synced 2025-10-09 13:56:40 +08:00
chore: fix auto link matcher
This commit is contained in:
parent
ef73299340
commit
55ecdae509
1 changed files with 12 additions and 0 deletions
|
@ -29,6 +29,18 @@ func (*AutoLinkParser) Match(tokens []*tokenizer.Token) (ast.Node, int) {
|
|||
urlStr = tokenizer.Stringify(matchedTokens[1 : len(matchedTokens)-1])
|
||||
isRawText = false
|
||||
} else {
|
||||
contentTokens := []*tokenizer.Token{}
|
||||
for _, token := range matchedTokens {
|
||||
if token.Type == tokenizer.Space {
|
||||
break
|
||||
}
|
||||
contentTokens = append(contentTokens, token)
|
||||
}
|
||||
if len(contentTokens) == 0 {
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
matchedTokens = contentTokens
|
||||
u, err := url.Parse(tokenizer.Stringify(matchedTokens))
|
||||
if err != nil || u.Scheme == "" || u.Host == "" {
|
||||
return nil, 0
|
||||
|
|
Loading…
Add table
Reference in a new issue