Skip to content

Commit ccbb827

Browse files
committed
Simplify _recordsFor function
It appears that it previously allowed the name and type to be optional. Since this is no longer the case, we can remove a lot of the logic from the function body now
1 parent 13f7ff5 commit ccbb827

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

lib/mdns-server.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,12 @@ Server.prototype._respondToQuery = function (query) {
9090
}
9191

9292
Server.prototype._recordsFor = function (name, type) {
93-
var self = this
94-
95-
type = type ? [type] : Object.keys(this.registry)
93+
if (!(type in this.registry)) return []
9694

97-
return flatten.depth(type.map(function (type) {
98-
if (!(type in self.registry)) return []
99-
if (name) {
100-
return self.registry[type].filter(function (record) {
101-
var _name = ~name.indexOf('.') ? record.name : record.name.split('.')[0]
102-
return dnsEqual(_name, name)
103-
})
104-
} else {
105-
return self.registry[type]
106-
}
107-
}), 1)
95+
return this.registry[type].filter(function (record) {
96+
var _name = ~name.indexOf('.') ? record.name : record.name.split('.')[0]
97+
return dnsEqual(_name, name)
98+
})
10899
}
109100

110101
function isDuplicateRecord (a) {

0 commit comments

Comments
 (0)