types: simplify return
This commit is contained in:
parent
7b6b1f32d5
commit
1c8d815476
25
src/types.jl
25
src/types.jl
|
@ -59,19 +59,18 @@ function Request(data::String)
|
||||||
"""x
|
"""x
|
||||||
s = endswith(data, "\r\n") ? data[1:end-2] : data
|
s = endswith(data, "\r\n") ? data[1:end-2] : data
|
||||||
m = match(reg, s)
|
m = match(reg, s)
|
||||||
if isnothing(m)
|
isnothing(m) &&
|
||||||
Request(nothing, nothing, nothing, nothing, nothing, false, data)
|
return Request(nothing, nothing, nothing, nothing, nothing, false, data)
|
||||||
else
|
|
||||||
Request(something(m["protocol"], "gemini"),
|
Request(something(m["protocol"], "gemini"),
|
||||||
m["host"], parse(Int, something(m["port"], "1965")),
|
m["host"], parse(Int, something(m["port"], "1965")),
|
||||||
# normpath prevents "./path" being different from "path", and
|
# normpath prevents "./path" being different from "path", and
|
||||||
# resolves also "../". The only problem is that "./" is
|
# resolves also "../". The only problem is that "./" is
|
||||||
# transformed to ".", so we filter it. the raw rapresentation
|
# transformed to ".", so we filter it. the raw rapresentation
|
||||||
# is still there, if needed
|
# is still there, if needed
|
||||||
isnothing(m["path"]) ? nothing : filter!(!=("."), split(normpath(m["path"]), "/")),
|
isnothing(m["path"]) ? nothing : filter!(!=("."), split(normpath(m["path"]), "/")),
|
||||||
isnothing(m["query"]) ? nothing : unescape(m["query"]),
|
isnothing(m["query"]) ? nothing : unescape(m["query"]),
|
||||||
true, data)
|
true, data)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Request(protocol, host, port, path, query)
|
function Request(protocol, host, port, path, query)
|
||||||
|
|
Loading…
Reference in New Issue