FIX: Onebox instagram links that contain the username profile

FIX: Onebox instagram links that contain the username profile

diff --git a/lib/onebox/engine/instagram_onebox.rb b/lib/onebox/engine/instagram_onebox.rb
index eabe5db..014d597 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)\/p\//)
+      matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/[a-zA-Z0-9]+\/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 e1d4ddf..2f106d4 100644
--- a/spec/lib/onebox/engine/instagram_onebox_spec.rb
+++ b/spec/lib/onebox/engine/instagram_onebox_spec.rb
@@ -19,4 +19,10 @@ describe Onebox::Engine::InstagramOnebox do
   it "includes description" 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
+    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
 end

GitHub sha: 912d579a

3 Likes

This commit has been mentioned on Discourse Meta. There might be relevant details there:

:+1:

2 Likes