Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Commit e6b8c4e

Browse files
committed
🐛 id normalizes 127.0.0.1 to localhost
Fixes `Tried getting a connection to `localhost:27017` but it is not in deployment `localhost:27017`` https://bugsnag.com/mongodb/mongodb-scope-server/errors/56216df502c5eb75 2147026f
1 parent 14a91c2 commit e6b8c4e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/model.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,8 @@ module.exports.getId = function(id) {
139139
if (typeof id === 'number') {
140140
id = 'localhost:' + id;
141141
}
142-
return id.toLowerCase().replace(hostname.toLowerCase(), 'localhost').replace('mongodb://', '');
142+
return id.toLowerCase()
143+
.replace(hostname.toLowerCase(), 'localhost')
144+
.replace('127.0.0.1', 'localhost')
145+
.replace('mongodb://', '');
143146
};

test/index.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ describe('mongodb-instance-model', function() {
2323
it('should remove mongodb://', function() {
2424
assert.equal(Instance.getId('mongodb://localhost:27017'), 'localhost:27017');
2525
});
26+
it('should substitute localhost for 127.0.0.1', function() {
27+
assert.equal(Instance.getId('127.0.0.1:27017'), 'localhost:27017');
28+
});
2629
});
2730
});

0 commit comments

Comments
 (0)