diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/git/hook.go | 2 | ||||
-rw-r--r-- | modules/log/stack.go | 2 | ||||
-rw-r--r-- | modules/markup/html.go | 6 | ||||
-rw-r--r-- | modules/markup/html_test.go | 4 | ||||
-rw-r--r-- | modules/repository/check.go | 2 | ||||
-rw-r--r-- | modules/setting/repository.go | 2 | ||||
-rw-r--r-- | modules/setting/setting.go | 6 | ||||
-rw-r--r-- | modules/structs/hook.go | 2 | ||||
-rw-r--r-- | modules/upload/upload.go | 6 | ||||
-rw-r--r-- | modules/util/sanitize.go | 2 | ||||
-rw-r--r-- | modules/webhook/slack.go | 12 |
11 files changed, 23 insertions, 23 deletions
diff --git a/modules/git/hook.go b/modules/git/hook.go index 2b9f90efd3..2de36dbdef 100644 --- a/modules/git/hook.go +++ b/modules/git/hook.go @@ -96,7 +96,7 @@ func (h *Hook) Update() error { return err } - err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm) + err := ioutil.WriteFile(h.path, []byte(strings.ReplaceAll(h.Content, "\r", "")), os.ModePerm) if err != nil { return err } diff --git a/modules/log/stack.go b/modules/log/stack.go index ffe9aa67cc..568c10cd00 100644 --- a/modules/log/stack.go +++ b/modules/log/stack.go @@ -69,7 +69,7 @@ func functionName(programCounter uintptr) []byte { name = name[period+1:] } // And we should just replace the interpunct with a dot - name = bytes.Replace(name, []byte("·"), []byte("."), -1) + name = bytes.ReplaceAll(name, []byte("·"), []byte(".")) return name } diff --git a/modules/markup/html.go b/modules/markup/html.go index bef6269a69..f5f811b59b 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -683,9 +683,9 @@ func shortLinkProcessorFull(ctx *postProcessCtx, node *html.Node, noLink bool) { absoluteLink := isLinkStr(link) if !absoluteLink { if image { - link = strings.Replace(link, " ", "+", -1) + link = strings.ReplaceAll(link, " ", "+") } else { - link = strings.Replace(link, " ", "-", -1) + link = strings.ReplaceAll(link, " ", "-") } if !strings.Contains(link, "/") { link = url.PathEscape(link) @@ -902,7 +902,7 @@ func emojiShortCodeProcessor(ctx *postProcessCtx, node *html.Node) { } alias := node.Data[m[0]:m[1]] - alias = strings.Replace(alias, ":", "", -1) + alias = strings.ReplaceAll(alias, ":", "") converted := emoji.FromAlias(alias) if converted == nil { // check if this is a custom reaction diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 7f820d3990..a018d74840 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -35,7 +35,7 @@ func TestRender_Commits(t *testing.T) { var sha = "65f1bf27bc3bf70f64657658635e66094edbcb4d" var commit = util.URLJoin(AppSubURL, "commit", sha) var subtree = util.URLJoin(commit, "src") - var tree = strings.Replace(subtree, "/commit/", "/tree/", -1) + var tree = strings.ReplaceAll(subtree, "/commit/", "/tree/") test(sha, `<p><a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`) test(sha[:7], `<p><a href="`+commit[:len(commit)-(40-7)]+`" rel="nofollow"><code>65f1bf2</code></a></p>`) @@ -235,7 +235,7 @@ func TestRender_emoji(t *testing.T) { setting.StaticURLPrefix = AppURL test := func(input, expected string) { - expected = strings.Replace(expected, "&", "&", -1) + expected = strings.ReplaceAll(expected, "&", "&") buffer := RenderString("a.md", input, setting.AppSubURL, nil) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) } diff --git a/modules/repository/check.go b/modules/repository/check.go index 90186d6a29..274576c348 100644 --- a/modules/repository/check.go +++ b/modules/repository/check.go @@ -120,7 +120,7 @@ func gatherMissingRepoRecords(ctx context.Context) ([]*models.Repository, error) return nil }, ); err != nil { - if strings.HasPrefix("Aborted gathering missing repo", err.Error()) { + if strings.HasPrefix(err.Error(), "Aborted gathering missing repo") { return nil, err } if err2 := models.CreateRepositoryNotice("gatherMissingRepoRecords: %v", err); err2 != nil { diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 96159e2f4a..0bb10199a8 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -253,7 +253,7 @@ func newRepository() { if err != nil { log.Fatal("Failed to get home directory: %v", err) } - homeDir = strings.Replace(homeDir, "\\", "/", -1) + homeDir = strings.ReplaceAll(homeDir, "\\", "/") // Determine and create root git repository path. sec := Cfg.Section("repository") diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 8088cffcdf..69f0080f64 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -405,7 +405,7 @@ func getAppPath() (string, error) { } // Note: we don't use path.Dir here because it does not handle case // which path starts with two "/" in Windows: "//psf/Home/..." - return strings.Replace(appPath, "\\", "/", -1), err + return strings.ReplaceAll(appPath, "\\", "/"), err } func getWorkPath(appPath string) string { @@ -422,7 +422,7 @@ func getWorkPath(appPath string) string { workPath = appPath[:i] } } - return strings.Replace(workPath, "\\", "/", -1) + return strings.ReplaceAll(workPath, "\\", "/") } func init() { @@ -524,7 +524,7 @@ func NewContext() { if err != nil { log.Fatal("Failed to get home directory: %v", err) } - homeDir = strings.Replace(homeDir, "\\", "/", -1) + homeDir = strings.ReplaceAll(homeDir, "\\", "/") LogLevel = getLogLevel(Cfg.Section("log"), "LEVEL", "Info") StacktraceLogLevel = getStacktraceLogLevel(Cfg.Section("log"), "STACKTRACE_LEVEL", "None") diff --git a/modules/structs/hook.go b/modules/structs/hook.go index a10dd4281c..45ae94f985 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -338,7 +338,7 @@ func ParsePushHook(raw []byte) (*PushPayload, error) { // Branch returns branch name from a payload func (p *PushPayload) Branch() string { - return strings.Replace(p.Ref, "refs/heads/", "", -1) + return strings.ReplaceAll(p.Ref, "refs/heads/", "") } // .___ diff --git a/modules/upload/upload.go b/modules/upload/upload.go index 97f0df0542..e430a5d8b3 100644 --- a/modules/upload/upload.go +++ b/modules/upload/upload.go @@ -76,7 +76,7 @@ func AddUploadContext(ctx *context.Context, uploadType string) { ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/releases/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/releases/attachments/remove" ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments" - ctx.Data["UploadAccepts"] = strings.Replace(setting.Repository.Release.AllowedTypes, "|", ",", -1) + ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Release.AllowedTypes, "|", ",") ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize } else if uploadType == "comment" { @@ -87,14 +87,14 @@ func AddUploadContext(ctx *context.Context, uploadType string) { } else { ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/attachments" } - ctx.Data["UploadAccepts"] = strings.Replace(setting.Attachment.AllowedTypes, "|", ",", -1) + ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Attachment.AllowedTypes, "|", ",") ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize } else if uploadType == "repo" { ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/upload-file" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/upload-remove" ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/upload-file" - ctx.Data["UploadAccepts"] = strings.Replace(setting.Repository.Upload.AllowedTypes, "|", ",", -1) + ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Upload.AllowedTypes, "|", ",") ctx.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles ctx.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize } diff --git a/modules/util/sanitize.go b/modules/util/sanitize.go index b1c17b29cf..a4f5479dfb 100644 --- a/modules/util/sanitize.go +++ b/modules/util/sanitize.go @@ -28,7 +28,7 @@ func URLSanitizedError(err error, unsanitizedURL string) error { // SanitizeMessage sanitizes a message which may contains a sensitive URL func SanitizeMessage(message, unsanitizedURL string) string { sanitizedURL := SanitizeURLCredentials(unsanitizedURL, true) - return strings.Replace(message, unsanitizedURL, sanitizedURL, -1) + return strings.ReplaceAll(message, unsanitizedURL, sanitizedURL) } // SanitizeURLCredentials sanitizes a url, either removing user credentials diff --git a/modules/webhook/slack.go b/modules/webhook/slack.go index 4c0b50ecab..aaecad6c67 100644 --- a/modules/webhook/slack.go +++ b/modules/webhook/slack.go @@ -71,9 +71,9 @@ func (s *SlackPayload) JSONPayload() ([]byte, error) { // see: https://api.slack.com/docs/formatting func SlackTextFormatter(s string) string { // replace & < > - s = strings.Replace(s, "&", "&", -1) - s = strings.Replace(s, "<", "<", -1) - s = strings.Replace(s, ">", ">", -1) + s = strings.ReplaceAll(s, "&", "&") + s = strings.ReplaceAll(s, "<", "<") + s = strings.ReplaceAll(s, ">", ">") return s } @@ -81,9 +81,9 @@ func SlackTextFormatter(s string) string { func SlackShortTextFormatter(s string) string { s = strings.Split(s, "\n")[0] // replace & < > - s = strings.Replace(s, "&", "&", -1) - s = strings.Replace(s, "<", "<", -1) - s = strings.Replace(s, ">", ">", -1) + s = strings.ReplaceAll(s, "&", "&") + s = strings.ReplaceAll(s, "<", "<") + s = strings.ReplaceAll(s, ">", ">") return s } |