Permalink
Browse files

Ignore case of profile image extension

Closes #414.
  • Loading branch information...
1 parent 13596bc commit 73760610e959ae868de23de3da661d237fbcb106 @sferik committed Jun 13, 2013
Showing with 17 additions and 1 deletion.
  1. +1 −1 lib/twitter/user.rb
  2. +16 −0 spec/twitter/user_spec.rb
View
@@ -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,
View
@@ -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
@@ -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

0 comments on commit 7376061

Please sign in to comment.