Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Added age restriction check. Related to #26
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanahuja committed Apr 30, 2020
1 parent 75bb54d commit 383eccc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
* InstagramFeed
*
* @version 1.3.6
* @version 1.3.7
*
* @author Javier Sanahuja Liebana <bannss1@gmail.com>
* @contributor csanahuja <csanahuja@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@jsanahuja/instagramfeed",
"description": "Instagram Feed without access token. Not using the Instagram API",
"homepage": "https://github.com/jsanahuja/InstagramFeed",
"version": "1.3.6",
"version": "1.3.7",
"keywords": [
"instagram",
"feed",
Expand Down
9 changes: 7 additions & 2 deletions src/InstagramFeed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* InstagramFeed
*
* @version 1.3.6
* @version 1.3.7
*
* @author Javier Sanahuja Liebana <bannss1@gmail.com>
* @contributor csanahuja <csanahuja@gmail.com>
Expand Down Expand Up @@ -85,7 +85,12 @@
xhr.onload = function(e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var data = xhr.responseText.split("window._sharedData = ")[1].split("<\/script>")[0];
try{
var data = xhr.responseText.split("window._sharedData = ")[1].split("<\/script>")[0];
}catch(error){
console.error("Instagram Feed: It looks like the profile you are trying to fetch is age restricted. See https://github.com/jsanahuja/InstagramFeed/issues/26");
return;
}
data = JSON.parse(data.substr(0, data.length - 1));
data = data.entry_data.ProfilePage || data.entry_data.TagPage;
if(typeof data === "undefined"){
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
* InstagramFeed
*
* @version 1.3.6
* @version 1.3.7
*
* @author Javier Sanahuja Liebana <bannss1@gmail.com>
* @contributor csanahuja <csanahuja@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion test/requirejs.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
* InstagramFeed
*
* @version 1.3.6
* @version 1.3.7
*
* @author Javier Sanahuja Liebana <bannss1@gmail.com>
* @contributor csanahuja <csanahuja@gmail.com>
Expand Down

0 comments on commit 383eccc

Please sign in to comment.