Skip to content

Commit

Permalink
Merge pull request #470 from LuYangP/strip_url
Browse files Browse the repository at this point in the history
Strip url before parse it
  • Loading branch information
gabrielpoca committed Dec 30, 2017
2 parents b4ae4c1 + c812ca7 commit 45bd021
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers/url_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def expand_absolute_urls(content, base_url)
end

def normalize_url(url, base_url)
uri = URI.parse(url)
uri = URI.parse(url.strip)

# resolve (protocol) relative URIs
if uri.relative?
base_uri = URI.parse(base_url)
base_uri = URI.parse(base_url.strip)
scheme = base_uri.scheme || "http"
uri = URI.join("#{scheme}://#{base_uri.host}", uri)
end
Expand Down

0 comments on commit 45bd021

Please sign in to comment.