diff options
Diffstat (limited to 'internal/db')
-rw-r--r-- | internal/db/ssh_key.go | 7 | ||||
-rw-r--r-- | internal/db/webhook_slack.go | 12 | ||||
-rw-r--r-- | internal/db/wiki.go | 2 |
3 files changed, 10 insertions, 11 deletions
diff --git a/internal/db/ssh_key.go b/internal/db/ssh_key.go index f1fc04aa..b53c66d6 100644 --- a/internal/db/ssh_key.go +++ b/internal/db/ssh_key.go @@ -112,10 +112,10 @@ func parseKeyString(content string) (string, error) { // Transform all legal line endings to a single "\n" // Replace all windows full new lines ("\r\n") - content = strings.Replace(content, "\r\n", "\n", -1) + content = strings.ReplaceAll(content, "\r\n", "\n") // Replace all windows half new lines ("\r"), if it happen not to match replace above - content = strings.Replace(content, "\r", "\n", -1) + content = strings.ReplaceAll(content, "\r", "\n") // Replace ending new line as its may cause unwanted behaviour (extra line means not a single line key | OpenSSH key) content = strings.TrimRight(content, "\n") @@ -374,8 +374,7 @@ func checkKeyContent(content string) error { func addKey(e Engine, key *PublicKey) (err error) { // Calculate fingerprint. - tmpPath := strings.Replace(path.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().Nanosecond()), - "id_rsa.pub"), "\\", "/", -1) + tmpPath := strings.ReplaceAll(path.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().Nanosecond()), "id_rsa.pub"), "\\", "/") _ = os.MkdirAll(path.Dir(tmpPath), os.ModePerm) if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil { return err diff --git a/internal/db/webhook_slack.go b/internal/db/webhook_slack.go index 289bcb28..adc75587 100644 --- a/internal/db/webhook_slack.go +++ b/internal/db/webhook_slack.go @@ -51,18 +51,18 @@ func (p *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 } 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 } diff --git a/internal/db/wiki.go b/internal/db/wiki.go index f2276b61..03e3a48d 100644 --- a/internal/db/wiki.go +++ b/internal/db/wiki.go @@ -33,7 +33,7 @@ func ToWikiPageURL(name string) string { // that are not belong to wiki repository. func ToWikiPageName(urlString string) string { name, _ := url.QueryUnescape(urlString) - return strings.Replace(strings.TrimLeft(path.Clean("/"+name), "/"), "/", " ", -1) + return strings.ReplaceAll(strings.TrimLeft(path.Clean("/"+name), "/"), "/", " ") } // WikiCloneLink returns clone URLs of repository wiki. |