1
0
Fork 0

hackdoc: when redirecting, skip ref if default

Change-Id: Ie1680500ede673c407c9c8f4bbbe6b7f6a41b422
master
q3k 2021-03-06 20:44:56 +00:00
parent 34d39cc8ed
commit 81262ff202
2 changed files with 10 additions and 2 deletions

View File

@ -205,7 +205,15 @@ func (r *request) handlePageAuto(dirpath string) {
}
if file {
http.Redirect(r.w, r.r, "/"+fpath+"?ref="+r.ref, 302)
ref := r.ref
if ref == flagGitwebDefaultBranch {
ref = ""
}
path := "/" + fpath
if ref != "" {
path += "?ref=" + ref
}
http.Redirect(r.w, r.r, path, 302)
return
}
}

View File

@ -21,7 +21,7 @@ func renderMarkdown(input []byte, ref string) []byte {
// master is the default branch - do not make special links for that, as
// that makes them kinda ugly.
if ref == "master" {
if ref == flagGitwebDefaultBranch {
ref = ""
}