Skip to content

Commit

Permalink
Remove the encoding of profile urls
Browse files Browse the repository at this point in the history
  • Loading branch information
timhaines committed Jan 14, 2016
1 parent 0cd119a commit 6d46bd6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/twitter/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def alias_method_sub(method, pattern, replacement)
# @param size [String, Symbol] The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'
# @return [Addressable::URI]
def profile_banner_uri(size = :web)
parse_encoded_uri(insecure_uri([@attrs[:profile_banner_url], size].join('/'))) unless @attrs[:profile_banner_url].nil?
parse_uri(insecure_uri([@attrs[:profile_banner_url], size].join('/'))) unless @attrs[:profile_banner_url].nil?
end
alias_method :profile_banner_url, :profile_banner_uri

Expand All @@ -35,7 +35,7 @@ def profile_banner_uri(size = :web)
# @param size [String, Symbol] The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'
# @return [Addressable::URI]
def profile_banner_uri_https(size = :web)
parse_encoded_uri([@attrs[:profile_banner_url], size].join('/')) unless @attrs[:profile_banner_url].nil?
parse_uri([@attrs[:profile_banner_url], size].join('/')) unless @attrs[:profile_banner_url].nil?
end
alias_method :profile_banner_url_https, :profile_banner_uri_https

Expand All @@ -51,7 +51,7 @@ def profile_banner_uri?
# @param size [String, Symbol] The size of the image. Must be one of: 'mini', 'normal', 'bigger' or 'original'
# @return [Addressable::URI]
def profile_image_uri(size = :normal)
parse_encoded_uri(insecure_uri(profile_image_uri_https(size))) unless @attrs[:profile_image_url_https].nil?
parse_uri(insecure_uri(profile_image_uri_https(size))) unless @attrs[:profile_image_url_https].nil?
end
alias_method :profile_image_url, :profile_image_uri

Expand All @@ -66,7 +66,7 @@ def profile_image_uri_https(size = :normal)
# https://a0.twimg.com/profile_images/1759857427/image1326743606.png
# https://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png
# https://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png
parse_encoded_uri(@attrs[:profile_image_url_https].sub(PROFILE_IMAGE_SUFFIX_REGEX, profile_image_suffix(size))) unless @attrs[:profile_image_url_https].nil?
parse_uri(@attrs[:profile_image_url_https].sub(PROFILE_IMAGE_SUFFIX_REGEX, profile_image_suffix(size))) unless @attrs[:profile_image_url_https].nil?
end
alias_method :profile_image_url_https, :profile_image_uri_https

Expand All @@ -79,8 +79,8 @@ def profile_image_uri?

private

def parse_encoded_uri(uri)
Addressable::URI.parse(URI.encode(uri))
def parse_uri(uri)
Addressable::URI.parse(uri)
end

def insecure_uri(uri)
Expand Down

0 comments on commit 6d46bd6

Please sign in to comment.