Skip to content

Commit

Permalink
Ignore case when parsing RTCIceProtocol
Browse files Browse the repository at this point in the history
Before we would fail to parse RTCIceProtocol if it was upcased.

Relates to #289
  • Loading branch information
Sean-Der committed Jan 10, 2019
1 parent 20619e8 commit 868c3b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rtciceprotocol.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package webrtc

import "fmt"
import (
"fmt"
"strings"
)

// RTCIceProtocol indicates the transport protocol type that is used in the
// ice.URL structure.
Expand All @@ -21,10 +24,10 @@ const (
)

func newRTCIceProtocol(raw string) (RTCIceProtocol, error) {
switch raw {
case rtcIceProtocolUDPStr:
switch {
case strings.EqualFold(rtcIceProtocolUDPStr, raw):
return RTCIceProtocolUDP, nil
case rtcIceProtocolTCPStr:
case strings.EqualFold(rtcIceProtocolTCPStr, raw):
return RTCIceProtocolTCP, nil
default:
return RTCIceProtocol(Unknown), fmt.Errorf("unknown protocol: %s", raw)
Expand Down
2 changes: 2 additions & 0 deletions rtciceprotocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func TestNewRTCIceProtocol(t *testing.T) {
{unknownStr, true, RTCIceProtocol(Unknown)},
{"udp", false, RTCIceProtocolUDP},
{"tcp", false, RTCIceProtocolTCP},
{"UDP", false, RTCIceProtocolUDP},
{"TCP", false, RTCIceProtocolTCP},
}

for i, testCase := range testCases {
Expand Down

0 comments on commit 868c3b7

Please sign in to comment.