mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
8c1a4da804
Read HISTORY.md https://github.com/kataras/iris/blob/master/HISTORY.md#sa-19-august-2017--v831 Former-commit-id: 23f7c1c0dc3bc64f27db591a9b22cd5934337891
39 lines
753 B
Go
39 lines
753 B
Go
package mvc
|
|
|
|
import (
|
|
"strings"
|
|
"unicode"
|
|
)
|
|
|
|
func findCtrlWords(ctrlName string) (w []string) {
|
|
end := len(ctrlName)
|
|
start := -1
|
|
for i, n := 0, end; i < n; i++ {
|
|
c := rune(ctrlName[i])
|
|
if unicode.IsUpper(c) {
|
|
// it doesn't count the last uppercase
|
|
if start != -1 {
|
|
end = i
|
|
w = append(w, strings.ToLower(ctrlName[start:end]))
|
|
}
|
|
start = i
|
|
continue
|
|
}
|
|
end = i + 1
|
|
|
|
}
|
|
|
|
// We can't omit the last name, we have to take it.
|
|
// because of controller names like
|
|
// "UserProfile", we need to return "user", "profile"
|
|
// if "UserController", we need to return "user"
|
|
// if "User", we need to return "user".
|
|
last := ctrlName[start:end]
|
|
if last == ctrlSuffix {
|
|
return
|
|
}
|
|
|
|
w = append(w, strings.ToLower(last))
|
|
return
|
|
}
|