Trim whitespace from names of objects on save
This commit is contained in:
parent
6d0bf1c68b
commit
8033d052fe
@ -100,6 +100,9 @@ func (m *Model) Save() error {
|
||||
|
||||
m.setDefaultStatus()
|
||||
|
||||
// ensure name is trimmed of whitespace
|
||||
m.Name = strings.TrimSpace(m.Name)
|
||||
|
||||
if m.ID == 0 {
|
||||
m.ID, err = Create(m)
|
||||
} else {
|
||||
|
@ -55,6 +55,9 @@ func (m *Model) Touch(created bool) {
|
||||
func (m *Model) Save() error {
|
||||
var err error
|
||||
|
||||
// ensure name is trimmed of whitespace
|
||||
m.Name = strings.TrimSpace(m.Name)
|
||||
|
||||
if m.ID == 0 {
|
||||
m.ID, err = Create(m)
|
||||
} else {
|
||||
|
@ -2,6 +2,7 @@ package upstream
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"npm/internal/database"
|
||||
@ -73,6 +74,9 @@ func (m *Model) Save(skipConfiguration bool) error {
|
||||
return fmt.Errorf("User ID must be specified")
|
||||
}
|
||||
|
||||
// ensure name is trimmed of whitespace
|
||||
m.Name = strings.TrimSpace(m.Name)
|
||||
|
||||
if !skipConfiguration {
|
||||
// Set this upstream as requiring reconfiguration
|
||||
m.Status = status.StatusReady
|
||||
|
Loading…
Reference in New Issue
Block a user