code.gitea.io/gitea@v1.21.7/services/auth/source/ldap/util.go (about)

     1  // Copyright 2021 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package ldap
     5  
     6  // composeFullName composes a firstname surname or username
     7  func composeFullName(firstname, surname, username string) string {
     8  	switch {
     9  	case len(firstname) == 0 && len(surname) == 0:
    10  		return username
    11  	case len(firstname) == 0:
    12  		return surname
    13  	case len(surname) == 0:
    14  		return firstname
    15  	default:
    16  		return firstname + " " + surname
    17  	}
    18  }