mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-24 07:52:54 +00:00
44 lines
639 B
Go
44 lines
639 B
Go
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))
|
|
})
|
|
}
|
|
}
|