Handle channel names ending with a slash better
This commit is contained in:
parent
f03b30eff6
commit
0f5c3b57d2
8 changed files with 96 additions and 40 deletions
43
server/index_data_test.go
Normal file
43
server/index_data_test.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetTabFromPath(t *testing.T) {
|
||||
cases := []struct {
|
||||
input string
|
||||
expectedServer string
|
||||
expectedChannel string
|
||||
}{
|
||||
{
|
||||
"/chat.freenode.net/%23r%2Fstuff%2F/",
|
||||
"chat.freenode.net",
|
||||
"#r/stuff/",
|
||||
}, {
|
||||
"/chat.freenode.net/%23r%2Fstuff%2F",
|
||||
"chat.freenode.net",
|
||||
"#r/stuff/",
|
||||
}, {
|
||||
"/chat.freenode.net/%23r%2Fstuff",
|
||||
"chat.freenode.net",
|
||||
"#r/stuff",
|
||||
}, {
|
||||
"/chat.freenode.net/%23stuff",
|
||||
"chat.freenode.net",
|
||||
"#stuff",
|
||||
}, {
|
||||
"/chat.freenode.net/%23stuff/cake",
|
||||
"",
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
server, channel := getTabFromPath(tc.input)
|
||||
assert.Equal(t, tc.expectedServer, server)
|
||||
assert.Equal(t, tc.expectedChannel, channel)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue