Skip to content

Commit

Permalink
Merge pull request #114 from BridgeAR/fix-custom-inspection
Browse files Browse the repository at this point in the history
Fix custom inspection (use util.inspect.custom symbol)
  • Loading branch information
stash committed Jun 25, 2018
2 parents fae3ca8 + a662bbb commit c761c55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/cookie.js
Expand Up @@ -31,6 +31,7 @@
'use strict';
var net = require('net');
var urlParse = require('url').parse;
var util = require('util');
var pubsuffix = require('./pubsuffix-psl');
var Store = require('./store').Store;
var MemoryCookieStore = require('./memstore').MemoryCookieStore;
Expand Down Expand Up @@ -756,6 +757,12 @@ Cookie.prototype.inspect = function inspect() {
'"';
};

// Use the new custom inspection symbol to add the custom inspect function if
// available.
if (util.inspect.custom) {
Cookie.prototype[util.inspect.custom] = Cookie.prototype.inspect;
}

Cookie.prototype.toJSON = function() {
var obj = {};

Expand Down
6 changes: 6 additions & 0 deletions lib/memstore.js
Expand Up @@ -50,6 +50,12 @@ MemoryCookieStore.prototype.inspect = function() {
return "{ idx: "+util.inspect(this.idx, false, 2)+' }';
};

// Use the new custom inspection symbol to add the custom inspect function if
// available.
if (util.inspect.custom) {
MemoryCookieStore.prototype[util.inspect.custom] = MemoryCookieStore.prototype.inspect;
}

MemoryCookieStore.prototype.findCookie = function(domain, path, key, cb) {
if (!this.idx[domain]) {
return cb(null,undefined);
Expand Down

0 comments on commit c761c55

Please sign in to comment.