Skip to content

Commit e24574c

Browse files
author
Jessica Lord
committed
style(url parser): lint
1 parent 8c8fe5a commit e24574c

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

lib/url_parser.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function(url, options, callback) {
1818

1919
if (result.protocol === 'mongodb+srv:') {
2020
if (result.hostname.split('.').length < 3) {
21-
return callback(new Error('uri does not have hostname, domainname and tld'))
21+
return callback(new Error('uri does not have hostname, domainname and tld'));
2222
}
2323

2424
result.domainLength = result.hostname.split('.').length;
@@ -39,12 +39,8 @@ module.exports = function(url, options, callback) {
3939
return callback(new Error('No addresses found at host'));
4040
}
4141

42-
for (var i = 0; i < addresses.length; i ++) {
43-
if (!matchesParentDomain(
44-
addresses[i].name,
45-
result.hostname,
46-
result.domainLength
47-
)) {
42+
for (var i = 0; i < addresses.length; i++) {
43+
if (!matchesParentDomain(addresses[i].name, result.hostname, result.domainLength)) {
4844
return callback(new Error('srv record does not share hostname with parent uri'));
4945
}
5046
}
@@ -81,7 +77,7 @@ module.exports = function(url, options, callback) {
8177
function matchesParentDomain(srvAddress, parentDomain, domains) {
8278
let srv = srvAddress.split('.');
8379
let parent = parentDomain.split('.');
84-
for (let i = 1; i <= (domains - 1); i ++) {
80+
for (let i = 1; i <= domains - 1; i++) {
8581
if (srv[srv.length - i] !== parent[parent.length - i]) {
8682
return false;
8783
}

test/functional/url_parser_tests.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ describe('Url SRV Parser', function() {
12491249
requires: { topology: ['single'] }
12501250
},
12511251
test: function(done) {
1252-
parse('mongodb+srv://10gen.cc', function(err, object) {
1252+
parse('mongodb+srv://10gen.cc', function(err) {
12531253
expect(err).to.exist;
12541254
expect(err.message).to.equal('uri does not have hostname, domainname and tld');
12551255
done();
@@ -1260,14 +1260,14 @@ describe('Url SRV Parser', function() {
12601260
/**
12611261
* @ignore
12621262
*/
1263-
it.skip("should fail because returned host name's parent (build.10gen.cc) misses 'test'", {
1263+
it.only("should fail because returned host name's parent (build.10gen.cc) misses 'test'", {
12641264
metadata: {
12651265
requires: { topology: ['single'] }
12661266
},
12671267
test: function(done) {
12681268
// TODO it does return 'test'
12691269
// test.build.10gen.cc
1270-
parse('mongodb+srv://test13.test.build.10gen.cc', function(err, object) {
1270+
parse('mongodb+srv://test13.test.build.10gen.cc', function(err) {
12711271
expect(err).to.exist;
12721272
expect(err.message).to.equal('srv record does not share hostname with parent uri');
12731273
done();
@@ -1283,7 +1283,7 @@ describe('Url SRV Parser', function() {
12831283
requires: { topology: ['single'] }
12841284
},
12851285
test: function(done) {
1286-
parse('mongodb+srv://test14.test.build.10gen.cc', function(err, object) {
1286+
parse('mongodb+srv://test14.test.build.10gen.cc', function(err) {
12871287
expect(err).to.exist;
12881288
expect(err.message).to.equal('srv record does not share hostname with parent uri');
12891289
done();
@@ -1294,12 +1294,12 @@ describe('Url SRV Parser', function() {
12941294
/**
12951295
* @ignore
12961296
*/
1297-
it("should fail because returned host name's part 'not-build' mismatches URI parent part 'build'", {
1297+
it("should fail because returned host name's 'not-build' mismatches URI parent 'build'", {
12981298
metadata: {
12991299
requires: { topology: ['single'] }
13001300
},
13011301
test: function(done) {
1302-
parse('mongodb+srv://test15.test.build.10gen.cc', function(err, object) {
1302+
parse('mongodb+srv://test15.test.build.10gen.cc', function(err) {
13031303
expect(err).to.exist;
13041304
expect(err.message).to.equal('srv record does not share hostname with parent uri');
13051305
done();
@@ -1310,12 +1310,12 @@ describe('Url SRV Parser', function() {
13101310
/**
13111311
* @ignore
13121312
*/
1313-
it("Should fail because returned host name's part 'not-10gen' mismatches URI parent part '10gen'", {
1313+
it("Should fail because returned host name's 'not-10gen' mismatches URI part '10gen'", {
13141314
metadata: {
13151315
requires: { topology: ['single'] }
13161316
},
13171317
test: function(done) {
1318-
parse('mongodb+srv://test16.test.build.10gen.cc', function(err, object) {
1318+
parse('mongodb+srv://test16.test.build.10gen.cc', function(err) {
13191319
expect(err).to.exist;
13201320
expect(err.message).to.equal('srv record does not share hostname with parent uri');
13211321
done();
@@ -1331,7 +1331,7 @@ describe('Url SRV Parser', function() {
13311331
requires: { topology: ['single'] }
13321332
},
13331333
test: function(done) {
1334-
parse('mongodb+srv://test17.test.build.10gen.cc', function(err, object) {
1334+
parse('mongodb+srv://test17.test.build.10gen.cc', function(err) {
13351335
expect(err).to.exist;
13361336
expect(err.message).to.equal('srv record does not share hostname with parent uri');
13371337
done();
@@ -1347,7 +1347,7 @@ describe('Url SRV Parser', function() {
13471347
requires: { topology: ['single'] }
13481348
},
13491349
test: function(done) {
1350-
parse('mongodb+srv://test18.test.build.10gen.cc', function(err, object) {
1350+
parse('mongodb+srv://test18.test.build.10gen.cc', function(err) {
13511351
expect(err).to.be.null;
13521352
done();
13531353
});

0 commit comments

Comments
 (0)