diff --git a/source/js/Core/Media/VMM.ExternalAPI.js b/source/js/Core/Media/VMM.ExternalAPI.js index 43d81a5..9b91f9e 100644 --- a/source/js/Core/Media/VMM.ExternalAPI.js +++ b/source/js/Core/Media/VMM.ExternalAPI.js @@ -1230,6 +1230,16 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { isInstagramUrl: function(url) { return url.match("instagr.am/p/") || url.match("instagram.com/p/"); + }, + + getInstagramIdFromUrl: function(url) { + try { + return d.split("\/p\/")[1].split("/")[0]; + } catch(e) { + trace("Invalid Instagram url: " + url); + return null; + } + } }, diff --git a/source/js/Core/Media/VMM.MediaType.js b/source/js/Core/Media/VMM.MediaType.js index 064b5e7..52941f2 100644 --- a/source/js/Core/Media/VMM.MediaType.js +++ b/source/js/Core/Media/VMM.MediaType.js @@ -92,8 +92,8 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') { } else if (VMM.ExternalAPI.instagram.isInstagramUrl(d)) { media.type = "instagram"; media.link = d; - media.id = d.split("\/p\/")[1].split("/")[0]; - success = true; + media.id = VMM.ExternalAPI.instagram.getInstagramIdFromUrl(d) + success = Boolean(media.id); } else if (d.match(/jpg|jpeg|png|gif/i) || d.match("staticmap") || d.match("yfrog.com") || d.match("twitpic.com")) { media.type = "image"; media.id = d;