Skip to content

Commit

Permalink
Ignore case of profile image extension
Browse files Browse the repository at this point in the history
Closes #414.
  • Loading branch information
sferik committed Jun 13, 2013
1 parent 13596bc commit 7376061
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/twitter/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Twitter
class User < Twitter::BasicUser
PROFILE_IMAGE_SUFFIX_REGEX = /_normal(\.gif|\.jpe?g|\.png)$/
PROFILE_IMAGE_SUFFIX_REGEX = /_normal(\.gif|\.jpe?g|\.png)$/i
include Twitter::Creatable
include Twitter::Exceptable
attr_reader :connections, :contributors_enabled, :default_profile,
Expand Down
16 changes: 16 additions & 0 deletions spec/twitter/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@
expect(user.profile_image_url(:mini)).to eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png"
end
end
context "with capitalized file extension" do
it "returns the correct image" do
user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://si0.twimg.com/profile_images/67759670/DSCN2136_normal.JPG")
expect(user.profile_image_url(:original)).to eq "http://si0.twimg.com/profile_images/67759670/DSCN2136.JPG"
expect(user.profile_image_url(:bigger)).to eq "http://si0.twimg.com/profile_images/67759670/DSCN2136_bigger.JPG"
expect(user.profile_image_url(:mini)).to eq "http://si0.twimg.com/profile_images/67759670/DSCN2136_mini.JPG"
end
end
end

describe "#profile_image_url_https" do
Expand Down Expand Up @@ -218,6 +226,14 @@
expect(user.profile_image_url_https(:mini)).to eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png"
end
end
context "with capitalized file extension" do
it "returns the correct image" do
user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://si0.twimg.com/profile_images/67759670/DSCN2136_normal.JPG")
expect(user.profile_image_url_https(:original)).to eq "https://si0.twimg.com/profile_images/67759670/DSCN2136.JPG"
expect(user.profile_image_url_https(:bigger)).to eq "https://si0.twimg.com/profile_images/67759670/DSCN2136_bigger.JPG"
expect(user.profile_image_url_https(:mini)).to eq "https://si0.twimg.com/profile_images/67759670/DSCN2136_mini.JPG"
end
end
end

describe "#profile_image_url?" do
Expand Down

0 comments on commit 7376061

Please sign in to comment.