aboutsummaryrefslogtreecommitdiff
path: root/appservice/names.go
diff options
context:
space:
mode:
Diffstat (limited to 'appservice/names.go')
-rw-r--r--appservice/names.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/appservice/names.go b/appservice/names.go
index 4a5d186..9ed00f8 100644
--- a/appservice/names.go
+++ b/appservice/names.go
@@ -8,14 +8,16 @@ import (
)
func roomAlias(protocol string, id RoomID) string {
- id2 := strings.ReplaceAll(string(id), "#", "")
- id2 = strings.ReplaceAll(id2, "@", "__")
-
- return fmt.Sprintf("_ezbr__%s__%s", id2, protocol)
+ return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
}
func userMxId(protocol string, id UserID) string {
- id2 := strings.ReplaceAll(string(id), "@", "__")
+ return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol)
+}
- return fmt.Sprintf("_ezbr__%s__%s", id2, protocol)
+func safeStringForId(in string) string {
+ id2 := strings.ReplaceAll(in, "#", "")
+ id2 = strings.ReplaceAll(id2, "@", "__")
+ id2 = strings.ReplaceAll(id2, ":", "_")
+ return id2
}