diff --git a/modules/repofiles/content.go b/modules/repofiles/content.go index 838bfabdc..620185805 100644 --- a/modules/repofiles/content.go +++ b/modules/repofiles/content.go @@ -188,6 +188,7 @@ func GetContents(repo *models.Repository, treePath, ref string, forList bool) (* } // Handle links if entry.IsRegular() || entry.IsLink() { + ref = fmt.Sprintf("%s", strings.Replace(ref, "%", "%25", -1)) downloadURL, err := url.Parse(fmt.Sprintf("%s/raw/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath)) if err != nil { return nil, err diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index eb1bef5a7..2e551ef83 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -1152,8 +1152,13 @@ func PrepareCompareDiff( ctx.ServerError("GetDiffRange", err) return false } - ctx.Data["Diff"] = diff - ctx.Data["DiffNotAvailable"] = diff.NumFiles == 0 + if diff.NumFiles == 0 { + ctx.Data["Diff"] = nil + ctx.Data["DiffNotAvailable"] = true + } else { + ctx.Data["Diff"] = diff + ctx.Data["DiffNotAvailable"] = false + } return false }