fix: create file branch name use escape
This commit is contained in:
parent
c617532f47
commit
c13048756b
|
@ -103,7 +103,7 @@ func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*
|
|||
if ref == "" {
|
||||
ref = repo.DefaultBranch
|
||||
}
|
||||
origRef := ref
|
||||
origRef := fmt.Sprintf("%s", url.PathEscape(ref))
|
||||
|
||||
// Check that the path given in opts.treePath is valid (not a git path)
|
||||
cleanTreePath := CleanUploadFileName(treePath)
|
||||
|
@ -188,7 +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))
|
||||
ref = fmt.Sprintf("%s", url.PathEscape(ref))
|
||||
downloadURL, err := url.Parse(fmt.Sprintf("%s/raw/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -197,6 +197,7 @@ func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*
|
|||
contentsResponse.DownloadURL = &downloadURLString
|
||||
}
|
||||
if !entry.IsSubModule() {
|
||||
ref = fmt.Sprintf("%s", url.PathEscape(ref))
|
||||
htmlURL, err := url.Parse(fmt.Sprintf("%s/src/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue