Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Prevent crash on Safari < 8; code review
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisaljoudi committed Mar 4, 2015
1 parent 7ad472e commit d096608
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions platform/safari/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@

/******************************************************************************/

if(navigator.userAgent.indexOf("Safari/6") === -1) { // If we're not on at least Safari 8
var _open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(m, u) {
if(u.lastIndexOf("safari-extension:", 0) === 0) {
var i = u.length, seeDot = false;
while(i --) {
if(u[i] === ".") {
seeDot = true;
}
else if(u[i] === "/") {
break;
}
}
if(seeDot === false) {
throw 'InvalidAccessError'; // Avoid crash
return;
}
}
_open.apply(this, arguments);
};
}
/******************************************************************************/

vAPI.app.restart = function() {};

/******************************************************************************/
Expand Down

0 comments on commit d096608

Please sign in to comment.