mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-11-03 04:27:16 -05:00
urlparse for lemmy community full name
This commit is contained in:
parent
3a7d2af100
commit
30fb8e80e9
@ -6,7 +6,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mrusme/neonmodem/models/author"
|
"github.com/mrusme/neonmodem/models/author"
|
||||||
@ -157,24 +156,12 @@ func (sys *System) Load() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func communityFullname(community types.CommunitySafe) (communityName string) {
|
func communityFullname(community types.CommunitySafe) (communityName string) {
|
||||||
instanceName := ""
|
url, err := url.Parse(community.ActorID)
|
||||||
if community.ActorID != "" {
|
if err != nil {
|
||||||
removeUrlScheme := strings.NewReplacer(
|
return community.Name
|
||||||
"http://", "",
|
} else {
|
||||||
"https://", "",
|
return community.Name + "@" + url.Host
|
||||||
)
|
|
||||||
instanceName = removeUrlScheme.Replace(
|
|
||||||
community.ActorID)
|
|
||||||
splitUrl := strings.Split(instanceName, "/")
|
|
||||||
if len(splitUrl) > 1 {
|
|
||||||
instanceName = splitUrl[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
communityName = community.Name
|
|
||||||
if instanceName != "" {
|
|
||||||
communityName += "@" + instanceName
|
|
||||||
}
|
|
||||||
return communityName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sys *System) ListForums() ([]forum.Forum, error) {
|
func (sys *System) ListForums() ([]forum.Forum, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user