mirror of
https://github.com/stashapp/stash.git
synced 2025-12-19 14:53:01 +01:00
24 lines
407 B
Go
24 lines
407 B
Go
package name
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// Resource version of a name
|
|
func (n Ident) Resource() Ident {
|
|
name := n.Underscore().String()
|
|
x := strings.FieldsFunc(name, func(r rune) bool {
|
|
return r == '_' || r == '/'
|
|
})
|
|
|
|
for i, w := range x {
|
|
if i == len(x)-1 {
|
|
x[i] = New(w).Pluralize().Pascalize().String()
|
|
continue
|
|
}
|
|
|
|
x[i] = New(w).Pascalize().String()
|
|
}
|
|
|
|
return New(strings.Join(x, ""))
|
|
}
|