Ensure default URL host never has a trailing /
#503
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A while back I did this funky thing where the environment variable that controls the default host in all the URL helpers is called
HOST_URL
, which implies it’s a URL, and then stuck things likehttps://api.monitoring.envirodatagov.org/
in it, which, well, is a URL, but definitely not a host, and further confused things.It turns out Rails will happily use the scheme provided in there anyway (!), so that was really convenient. But what it failed to do was handle the trailing slash—an absolute path also starts with one, so you wind up getting URLs like
https://api.monitoring.envirodatagov.org//whatever
(not the double slash at the start of the path). While we should have more correct configuration, we could also gracefully handle incorrect configuration by removing trailing slashes, which is what this PR does.Fixes #301.