Skip to content

Commit

Permalink
Fix trimming of leading and trailing spaces when adding a new file
Browse files Browse the repository at this point in the history
  • Loading branch information
charles7668 committed Jun 27, 2024
1 parent 00fc29a commit 0c3e581
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions routers/web/repo/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,14 @@ func EditFilePost(ctx *context.Context) {
// NewFilePost response for creating file
func NewFilePost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditRepoFileForm)

// trim leading and trailing spaces from the tree path
treePath := strings.Split(form.TreePath, "/")
for i, v := range treePath {
treePath[i] = strings.TrimSpace(v)
}
form.TreePath = strings.Join(treePath, "/")

editFilePost(ctx, *form, true)
}

Expand Down

0 comments on commit 0c3e581

Please sign in to comment.