You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error happens because uri.path can return nil. (The union type in the error is (String | Nil)).
A way to handle this is:
require"http/client"
uri =URI.parse "https://example.com/help"
client =HTTP::Client.new uri
if path = uri.path
client.get(path) { |_| puts"hello" }
end
The if path = uri.path check ensures that path is not nil.
You probably want uri.path || "/" here, since https://example.com will have a nil path, whereas you probably want that to be the same as https://example.com/
Submitting bugs
This code works as expected:
But with this change it fails:
I expect
uri.path
should work, because it holds the same string as"/help"
:carc.in
long error log
Crystal 0.26.1 [3917852] (2018-08-27)
LLVM: 4.0.0
Default target: x86_64-unknown-linux-gnu
The text was updated successfully, but these errors were encountered: