diff options
author | Sasha Varlamov <sasha@sashavarlamov.com> | 2017-12-07 14:00:09 +0700 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-07 15:00:09 +0800 |
commit | 311c83ad17c718f1b81c94f84307b4288c90e374 (patch) | |
tree | a2d962fdeb7637d5f02351abac58584eb0ef90ec /routers/utils/utils.go | |
parent | 7ec6cddd27f36f50f06669b208674feb0dc19535 (diff) | |
download | gitea-311c83ad17c718f1b81c94f84307b4288c90e374.tar.gz gitea-311c83ad17c718f1b81c94f84307b4288c90e374.zip |
Allow adding collaborators with (fullname) (#3103)
* Allow adding collaborators with (fullname)
Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com>
* Refactor username suffix to utils pkg
Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com>
Diffstat (limited to 'routers/utils/utils.go')
-rw-r--r-- | routers/utils/utils.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/routers/utils/utils.go b/routers/utils/utils.go new file mode 100644 index 0000000000..6ead7d60e2 --- /dev/null +++ b/routers/utils/utils.go @@ -0,0 +1,17 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package utils + +import ( + "strings" +) + +// RemoveUsernameParameterSuffix returns the username parameter without the (fullname) suffix - leaving just the username +func RemoveUsernameParameterSuffix(name string) string { + if index := strings.Index(name, " ("); index >= 0 { + name = name[:index] + } + return name +} |