FIX: Onebox instagram links correctly

FIX: Onebox instagram links correctly

diff --git a/lib/onebox/engine/instagram_onebox.rb b/lib/onebox/engine/instagram_onebox.rb
index 014d597..eee30b4 100644
--- a/lib/onebox/engine/instagram_onebox.rb
+++ b/lib/onebox/engine/instagram_onebox.rb
@@ -7,7 +7,7 @@ module Onebox
       include StandardEmbed
       include LayoutSupport
 
-      matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/[a-zA-Z0-9]+\/p\//)
+      matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\//)
       always_https
 
       def data
diff --git a/spec/lib/onebox/engine/instagram_onebox_spec.rb b/spec/lib/onebox/engine/instagram_onebox_spec.rb
index 2f106d4..7c2c919 100644
--- a/spec/lib/onebox/engine/instagram_onebox_spec.rb
+++ b/spec/lib/onebox/engine/instagram_onebox_spec.rb
@@ -20,9 +20,15 @@ describe Onebox::Engine::InstagramOnebox do
     expect(html).to include("1.2m Likes, 6,100 Comments - National Geographic (@natgeo) on Instagram")
   end
 
-  it 'Oneboxes links that include the username' do
+  it 'oneboxes links that include the username' do
     link_with_profile = 'https://www.instagram.com/bennyblood24/p/Brc6FNRn9vu/'
     onebox_klass = Onebox::Matcher.new(link_with_profile).oneboxed
     expect(onebox_klass.name).to eq(described_class.name)
   end
+
+  it 'oneboxes photo links' do
+    photo_link = 'https://www.instagram.com/p/Brc6FNRn9vu/'
+    onebox_klass = Onebox::Matcher.new(photo_link).oneboxed
+    expect(onebox_klass.name).to eq(described_class.name)
+  end
 end

GitHub sha: 7ecf279c

1 Like