1
0
Fork 0
forked from External/mediamtx
mediamtx/internal/protocols/httpp/location_with_trailing_slash.go
2024-02-13 13:04:56 +01:00

22 lines
356 B
Go

package httpp
import "net/url"
// LocationWithTrailingSlash returns the URL in a relative format, with a trailing slash.
func LocationWithTrailingSlash(u *url.URL) string {
l := "./"
for i := 1; i < len(u.Path); i++ {
if u.Path[i] == '/' {
l += "../"
}
}
l += u.Path[1:] + "/"
if u.RawQuery != "" {
l += "?" + u.RawQuery
}
return l
}