pull/231/merge
Gustavo Bittencourt 2020-11-06 13:47:16 +01:00 committed by GitHub
commit 8a785e3ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 24 deletions

28
html.go
View File

@ -18,6 +18,7 @@ package blackfriday
import (
"bytes"
"fmt"
"net/url"
"regexp"
"strconv"
"strings"
@ -897,31 +898,10 @@ func doubleSpace(out *bytes.Buffer) {
}
func isRelativeLink(link []byte) (yes bool) {
// a tag begin with '#'
if link[0] == '#' {
return true
u, err := url.Parse(string(link))
if err == nil {
return !u.IsAbs()
}
// link begin with '/' but not '//', the second maybe a protocol relative link
if len(link) >= 2 && link[0] == '/' && link[1] != '/' {
return true
}
// only the root '/'
if len(link) == 1 && link[0] == '/' {
return true
}
// current directory : begin with "./"
if bytes.HasPrefix(link, []byte("./")) {
return true
}
// parent directory : begin with "../"
if bytes.HasPrefix(link, []byte("../")) {
return true
}
return false
}