all repos — grayfriday @ a2702e7449e04ec7ce90428fbc707d8293eca27e

blackfriday fork with a few changes

Simplify isRelativeLink() a bit
Vytautas Ĺ altenis vytas@rtfb.lt
Sat, 11 Apr 2015 18:06:30 +0300
commit

a2702e7449e04ec7ce90428fbc707d8293eca27e

parent

b3137e7c8fdcaacce02eee9aaf15b50ec559bb34

1 files changed, 8 insertions(+), 10 deletions(-)

jump to
M html.gohtml.go

@@ -874,34 +874,32 @@ }

} func isRelativeLink(link []byte) (yes bool) { - yes = false - // a tag begin with '#' if link[0] == '#' { - yes = true + return true } // link begin with '/' but not '//', the second maybe a protocol relative link if len(link) >= 2 && link[0] == '/' && link[1] != '/' { - yes = true + return true } // only the root '/' if len(link) == 1 && link[0] == '/' { - yes = true + return true } // current directory : begin with "./" - if len(link) >= 2 && link[0] == '.' && link[1] == '/' { - yes = true + if bytes.HasPrefix(link, []byte("./")) { + return true } // parent directory : begin with "../" - if len(link) >= 3 && link[0] == '.' && link[1] == '.' && link[2] == '/' { - yes = true + if bytes.HasPrefix(link, []byte("../")) { + return true } - return + return false } func (options *Html) ensureUniqueHeaderID(id string) string {