Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url coercer #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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
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