Skip to content

Conversation

@locochris
Copy link

@locochris locochris commented Mar 23, 2018

Our app was recently tripped up because a uri variable was set to server.example.com instead of https://server.example.com (as both can be parsed by URI.parse).
We were using:

variable :SERVER_URL, :uri

but that resulted in:

URI.parse('server.example.com')
=> #<URI::Generic server.example.com>

instead of raising an exception.

So this PR adds a uri_with_scheme coercer to make sure the resulting URI has a scheme eg http for URI:HTTP or https for URI:HTTPS but does not let through a scheme-less uri like URI:Generic.
To be used as:

variable :SERVER_URL, :uri_with_scheme

which will raise an exception unless a valid uri that contains a scheme is used.

@locochris locochris force-pushed the add_url_coercer branch 3 times, most recently from d838d74 to b102161 Compare March 26, 2018 02:53
@eval eval added bug and removed bug labels Sep 3, 2019
@eval eval added the bug label Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants