add support for TCP routes (#1695)

This commit is contained in:
Caleb Doxsey 2020-12-16 13:09:48 -07:00 committed by GitHub
parent 64816720c8
commit ad828c6e84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 13 deletions

View file

@ -153,7 +153,7 @@ allowed_route_regex(input_url_obj, policy) {
parse_url(str) = { "scheme": scheme, "host": host, "path": path } {
[_, scheme, host, rawpath] = regex.find_all_string_submatch_n(
`(?:(http[s]?)://)?([^/]+)([^?#]*)`,
`(?:((?:tcp[+])?http[s]?)://)?([^/]+)([^?#]*)`,
str, 1)[0]
path = normalize_url_path(rawpath)
}

View file

@ -301,6 +301,13 @@ test_parse_url {
url.path == "/some/path"
}
test_parse_tcp_url {
url := parse_url("tcp+http://example.com/some/path?qs")
url.scheme == "tcp+http"
url.host == "example.com"
url.path == "/some/path"
}
test_allowed_route_source {
allowed_route("http://example.com", {"source": "example.com"})
allowed_route("http://example.com", {"source": "http://example.com"})

File diff suppressed because one or more lines are too long