Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ const (
)

func checkID(id, kind string, sigil byte) (err error) {
if _, err = domainFromID(id); err != nil {
return
if kind == "room" {
if _, err = spec.ParseAndValidateRoomID(id); err != nil {
return
}
}
if id[0] != sigil {
err = fmt.Errorf(
Expand Down
4 changes: 2 additions & 2 deletions spec/roomid.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RoomID struct {
}

func NewRoomID(id string) (*RoomID, error) {
return parseAndValidateRoomID(id)
return ParseAndValidateRoomID(id)
}

// Returns the full roomID string including leading sigil
Expand All @@ -41,7 +41,7 @@ func (room RoomID) Domain() ServerName {
return ServerName(room.domain)
}

func parseAndValidateRoomID(id string) (*RoomID, error) {
func ParseAndValidateRoomID(id string) (*RoomID, error) {
idLength := len(id)
if idLength < 4 { // 4 since minimum roomID includes an !, :, non-empty opaque ID, non-empty domain
return nil, fmt.Errorf("length %d is too short to be valid", idLength)
Expand Down
Loading