Skip to content

Commit

Permalink
getMyURL fix for PhantomJS 1
Browse files Browse the repository at this point in the history
  • Loading branch information
querymetrics authored and nicjansma committed Apr 4, 2018
1 parent 2d2cfd0 commit a1ca875
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions boomerang.js
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ BOOMR_check_doc_domain();
arrayFilter: function(array, predicate) {
var result = [];

if (!(BOOMR.utils.isArray(array) || (array && typeof array.length === "number")) ||
if (!(this.isArray(array) || (array && typeof array.length === "number")) ||
typeof predicate !== "function") {
return result;
}
Expand Down Expand Up @@ -1449,7 +1449,7 @@ BOOMR_check_doc_domain();
* @memberof BOOMR.utils
*/
arrayFind: function(array, predicate) {
if (!(BOOMR.utils.isArray(array) || (array && typeof array.length === "number")) ||
if (!(this.isArray(array) || (array && typeof array.length === "number")) ||
typeof predicate !== "function") {
return undefined;
}
Expand Down Expand Up @@ -1784,6 +1784,7 @@ BOOMR_check_doc_domain();
* @returns {string} The URL of the currently executing boomerang script.
*/
getMyURL: function() {
var stack;
// document.currentScript works in all browsers except for IE: https://caniuse.com/#feat=document-currentscript
// #boomr-if-as works in all browsers if the page uses our standard iframe loader
// #boomr-scr-as works in all browsers if the page uses our preloader loader
Expand Down Expand Up @@ -1815,7 +1816,10 @@ BOOMR_check_doc_domain();
}
catch (e) {
if ("stack" in e) {
return boomr.utils.arrayFilter(e.stack.split(/\n/), function(l) { return l.match(/https?:\/\//); })[0].replace(/.*(https?:\/\/.+):\d+:\d+\D*$/m, "$1");
stack = this.arrayFilter(e.stack.split(/\n/), function(l) { return l.match(/https?:\/\//); });
if (stack && stack.length) {
return stack[0].replace(/.*(https?:\/\/.+?)(:\d+)+\D*$/m, "$1");
}
}
// FWIW, on IE 8 & 9, the Error object does not contain a stack property, but if you have an uncaught error,
// and a `window.onerror` handler (not using addEventListener), then the second argument to that handler is
Expand Down

0 comments on commit a1ca875

Please sign in to comment.