Skip to content

Commit 4f31f6e

Browse files
committed
check page headers to determine Solidus status
1 parent 2bae156 commit 4f31f6e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

background.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,18 @@ function getJsonResource(tabID) {
4949
var xhr = new XMLHttpRequest();
5050
xhr.open("GET", jsonResourceURL, true);
5151
xhr.onreadystatechange = function() {
52-
if (xhr.readyState === 4){
53-
if(xhr.status === 200){
52+
if (xhr.readyState === 4 && xhr.getResponseHeader("X-Powered-By") === "Express") {
53+
if(xhr.status === 200){ //Check this separately so we can notify devtools if we don't get a 200 response.
5454
try {
55-
pageContext = JSON.parse(xhr.responseText);
56-
notifyDevtools(pageContext);
55+
notifyDevtools(JSON.parse(xhr.responseText));
5756
} catch (e) {
5857
notifyDevtools(JSON.parse('{"error":"' + e + '"}'));
5958
}
6059
} else {
61-
notifyDevtools(JSON.parse('{"error":"No Solidus Page Context Found!"}'));
60+
notifyDevtools(JSON.parse('{"error":"Solidus Page Context Not Found!"}'));
6261
}
62+
} else {
63+
notifyDevtools(JSON.parse('{"error":"Looks like you\'re not inspecting a Solidus Page."}'));
6364
}
6465
}
6566
xhr.send();

0 commit comments

Comments
 (0)