Skip to content
Snippets Groups Projects
Commit 191a9007 authored by CamilleC's avatar CamilleC
Browse files

fix getEndpoints

parent c69ccaea
No related branches found
No related tags found
1 merge request!285node's list header
...@@ -59,16 +59,9 @@ function Peer(json) { ...@@ -59,16 +59,9 @@ function Peer(json) {
that.getEndpoints = function(regex) { that.getEndpoints = function(regex) {
if (!regex) return that.endpoints; if (!regex) return that.endpoints;
// Use string regex
if (typeof regex === "string") {
return that.endpoints.reduce(function(res, ep){ return that.endpoints.reduce(function(res, ep){
return ep.match(regex) ? res.concat(ep) : res; return ep.match(regex) ? res.concat(ep) : res;
}, []); }, []);
}
// use Regex object
return that.endpoints.reduce(function(res, ep){
return regex.test(regex) ? res.concat(ep) : res;
}, []);
}; };
that.hasEndpoint = function(endpoint){ that.hasEndpoint = function(endpoint){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment