Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: attach remaining non-enumerables to req
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Oct 6, 2017
1 parent e1befaa commit 5d8556a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,30 @@ extend(Raven.prototype, {
* (eg. globalContext.request + domainContext.request + kwargs.request),
* we manually pull them out from original objects.
*
* Same scenario happens when some frameworks (eg. Koa) decide to use request within
* request. eg `this.request.req`, which adds aliases to the main `request` object.
* By manually reassigning them here, we don't need to add additional checks
* like `req.method || (req.req && req.req.method)`
*
* We don't use Object.assign/extend as it's only merging over objects own properties,
* and we don't want to go through all of the properties as well, as we simply don't
* need all of them.
*
* So far the only missing piece is `ip`, but we can specify what properties should
* be pulled by extending `nonEnumerables` array.
**/
var sources = Array.from(arguments).filter(function(source) {
return Object.prototype.toString.call(source) === '[object Object]';
});
sources = [{}].concat(sources);
var request = extend.apply(null, sources);
var nonEnumberables = ['ip'];
var nonEnumberables = [
'headers',
'host',

This comment has been minimized.

Copy link
@oliviertassinari

oliviertassinari Dec 27, 2017

Contributor

This change is introducing the following warning on my end:

express deprecated req.host: Use req.hostname instead node_modules/raven/lib/client.js:596:47

It's related to #101.

'ip',
'method',
'protocol',
'query',
'secure',
'url'
];

nonEnumberables.forEach(function(key) {
sources.forEach(function(source) {
Expand Down

0 comments on commit 5d8556a

Please sign in to comment.