mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 13:35:23 +00:00
fix: add valid test identified by linter
This commit is contained in:
parent
046116656b
commit
ae6a20e4d9
@ -271,9 +271,9 @@ func (n *Namespace) toProto() *v1.Namespace {
|
|||||||
func NormalizeNamespaceName(name string, stripEmailDomain bool) (string, error) {
|
func NormalizeNamespaceName(name string, stripEmailDomain bool) (string, error) {
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
name = strings.ReplaceAll(name, "'", "")
|
name = strings.ReplaceAll(name, "'", "")
|
||||||
if stripEmailDomain {
|
atIdx := strings.Index(name, "@")
|
||||||
idx := strings.Index(name, "@")
|
if stripEmailDomain && atIdx > 0 {
|
||||||
name = name[:idx]
|
name = name[:atIdx]
|
||||||
} else {
|
} else {
|
||||||
name = strings.ReplaceAll(name, "@", ".")
|
name = strings.ReplaceAll(name, "@", ".")
|
||||||
}
|
}
|
||||||
|
@ -280,6 +280,15 @@ func TestNormalizeNamespaceName(t *testing.T) {
|
|||||||
want: "foo.bar",
|
want: "foo.bar",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "strip enabled no email passed as argument",
|
||||||
|
args: args{
|
||||||
|
name: "not-email-and-strip-enabled",
|
||||||
|
stripEmailDomain: true,
|
||||||
|
},
|
||||||
|
want: "not-email-and-strip-enabled",
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "normalize complex email",
|
name: "normalize complex email",
|
||||||
args: args{
|
args: args{
|
||||||
|
Loading…
Reference in New Issue
Block a user