File tree 1 file changed +7
-8
lines changed 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ import (
7
7
"errors"
8
8
"net/http"
9
9
"strings"
10
- "unicode"
11
10
12
11
issues_model "code.gitea.io/gitea/models/issues"
13
12
api "code.gitea.io/gitea/modules/structs"
14
13
"code.gitea.io/gitea/modules/web"
15
14
"code.gitea.io/gitea/services/context"
15
+
16
+ "golang.org/x/text/cases"
17
+ "golang.org/x/text/language"
16
18
)
17
19
18
20
// LockIssue lock an issue
@@ -55,15 +57,12 @@ func LockIssue(ctx *context.APIContext) {
55
57
// "404":
56
58
// "$ref": "#/responses/notFound"
57
59
60
+ caser := cases .Title (language .English )
58
61
reason := web .GetForm (ctx ).(* api.LockIssueOption ).Reason
59
62
reason = strings .ToLower (reason )
60
-
61
- if reason != "" {
62
- // make the first character uppercase
63
- runes := []rune (reason )
64
- runes [0 ] = unicode .ToUpper (runes [0 ])
65
- reason = string (runes )
66
- }
63
+ reason_parts := strings .Split (reason , " " )
64
+ reason_parts [0 ] = caser .String (reason_parts [0 ])
65
+ reason = strings .Join (reason_parts , " " )
67
66
68
67
if ! issues_model .IsValidReason (reason ) {
69
68
ctx .APIError (http .StatusBadRequest , errors .New ("reason not valid" ))
You can’t perform that action at this time.
0 commit comments