golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
639 B
43 lines
639 B
package httpp |
|
|
|
import ( |
|
"net/url" |
|
"testing" |
|
|
|
"github.com/stretchr/testify/require" |
|
) |
|
|
|
func TestLocationWithTrailingSlash(t *testing.T) { |
|
for _, ca := range []struct { |
|
name string |
|
url *url.URL |
|
loc string |
|
}{ |
|
{ |
|
"with query", |
|
&url.URL{ |
|
Path: "/test", |
|
RawQuery: "key=value", |
|
}, |
|
"./test/?key=value", |
|
}, |
|
{ |
|
"xss", |
|
&url.URL{ |
|
Path: "/www.example.com", |
|
}, |
|
"./www.example.com/", |
|
}, |
|
{ |
|
"slashes in path", |
|
&url.URL{ |
|
Path: "/my/path", |
|
}, |
|
"./../my/path/", |
|
}, |
|
} { |
|
t.Run(ca.name, func(t *testing.T) { |
|
require.Equal(t, ca.loc, LocationWithTrailingSlash(ca.url)) |
|
}) |
|
} |
|
}
|
|
|