8000 1.1.0-rc3 · webworkadmin/raven-js@be2af1a · GitHub
[go: up one dir, main page]

Skip to content

Commit be2af1a

Browse files
committed
1.1.0-rc3
1 parent 067521d commit be2af1a

File tree

5 files changed

+60
-37
lines changed

5 files changed

+60
-37
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raven-js",
3-
"version": "1.1.0-rc2",
3+
"version": "1.1.0-rc3",
44
"dependencies": {},
55
"main": "dist/raven.js"
66
}

dist/raven.js

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 1.1.0-rc2 (eafd5f4) | github.com/getsentry/raven-js */
1+
/*! Raven.js 1.1.0-rc3 (067521d) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit
@@ -1132,7 +1132,7 @@ TK.remoteFetching = false;
11321132
* @this {Raven}
11331133
*/
11341134
var Raven = {
1135-
VERSION: '1.1.0-rc2',
1135+
VERSION: '1.1.0-rc3',
11361136

11371137
// Expose TraceKit to the Raven namespace
11381138
TraceKit: TK,
@@ -1258,29 +1258,55 @@ var Raven = {
12581258
* @return {function} The newly wrapped functions with a context
12591259
*/
12601260
wrap: function(options, func) {
1261+
// 1 argument has been passed, and it's not a function
1262+
// so just return it
1263+
if (isUndefined(func) && !isFunction(options)) {
1264+
return options;
1265+
}
1266+
12611267
// options is optional
12621268
if (isFunction(options)) {
12631269
func = options;
12641270
options = undefined;
12651271
}
12661272

1267-
var property,
1268-
wrappedFunction = function() {
1269-
try {
1270-
return func.apply(this, arguments);
1271-
} catch(e) {
1272-
Raven.captureException(e, options);
1273-
throw e;
1274-
}
1275-
};
1273+
// At this point, we've passed along 2 arguments, and the second one
1274+
// is not a function either, so we'll just return the second argument.
1275+
if (!isFunction(func)) {
1276+
return func;
1277+
}
12761278

1277-
for (property in func) {
1279+
// We don't wanna wrap it twice!
1280+
if (func.__raven__) {
1281+
return func;
1282+
}
1283+
1284+
var self = this;
1285+
1286+
function wrapped() {
1287+
var args = [], i = arguments.length;
1288+
// Recursively wrap all of a function's arguments that are
1289+
// functions themselves.
1290+
while(i--) args[i] = Raven.wrap(options, arguments[i]);
1291+
try {
1292+
return func.apply(self, args);
1293+
} catch(e) {
1294+
Raven.captureException(e, options);
1295+
}
1296+
}
1297+
1298+
// copy over properties of the old function
1299+
for (var property in func) {
12781300
if (func.hasOwnProperty(property)) {
1279-
wrappedFunction[property] = func[property];
1301+
wrapped[property] = func[property];
12801302
}
12811303
}
12821304

1283-
return wrappedFunction;
1305+
// Signal that this function has been wrapped already
1306+
// for both debugging and to prevent it to being wrapped twice
1307+
wrapped.__raven__ = true;
1308+
1309+
return wrapped;
12841310
},
12851311

12861312
/*
@@ -1421,6 +1447,10 @@ function isFunction(what) {
14211447
return typeof what === 'function';
14221448
}
14231449

1450+
function isString(what) {
1451+
return typeof what === 'string';
1452+
}
1453+
14241454
function each(obj, callback) {
14251455
var i, j;
14261456

@@ -1703,27 +1733,20 @@ function isSetup() {
17031733
return true;
17041734
}
17051735

1706-
function wrapArguments(what) {
1707-
if (!isFunction(what)) return what;
1708-
1709-
function wrapped() {
1710-
var args = [], i = arguments.length, arg;
1711-
while(i--) {
1712-
arg = arguments[i];
1713-
args[i] = isFunction(arg) ? Raven.wrap(arg) : arg;
1714-
}
1715-
what.apply(null, args);
1716-
}
1717-
// copy over properties of the old function
1718-
for (var k in what) wrapped[k] = what[k];
1719-
return wrapped;
1720-
}
1721-
17221736
function joinRegExp(patterns) {
1723-
// Combine an array of regular expressions into one large regexp
1737+
// Combine an array of regular expressions and strings into one large regexp
17241738
var sources = [], i = patterns.length;
17251739
// lol, map
1726-
while (i--) sources[i] = patterns[i].source;
1740+
while (i--) {
1741+
if (isString(patterns[i])) {
1742+
// If it's a string, we need to escape it
1743+
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
1744+
sources[i] = patterns[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
1745+
} else {
1746+
// If it's a regexp already, we want to extract the source
1747+
sources[i] = patterns[i].source;
1748+
}
1749+
}
17271750
return new RegExp(sources.join('|'), 'i');
17281751
}
17291752

dist/raven.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0