[tor-commits] [atlas/master] Support bandwidth values that are zero
    irl at torproject.org 
    irl at torproject.org
       
    Sat Apr 22 15:23:41 UTC 2017
    
    
  
commit 547b1cdbf5edc567bed762edbda7ea462220f8e0
Author: cypherpunks <cypherpunks at torproject.org>
Date:   Fri Apr 21 14:44:55 2017 +0000
    Support bandwidth values that are zero
    
    The boolean value of zero is false in JavaScript. This means that
    bandwidth values that are zero are set to 'null'. Null values result in
    empty fields in the router details and search pages.
    
    The checks are meant to catch undefined variables so they are replaced
    by typeof comparisons which are stricter.
    
    Closes #22039.
---
 js/models/relay.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/js/models/relay.js b/js/models/relay.js
index a578e99..ab938af 100644
--- a/js/models/relay.js
+++ b/js/models/relay.js
@@ -156,11 +156,11 @@ define([
                     relay.exit_policy = relay.exit_policy ? relay.exit_policy : null;
                     relay.exit_policy_summary = relay.exit_policy_summary ?  relay.exit_policy_summary : null;
                     relay.exit_policy_v6_summary = relay.exit_policy_v6_summary ?  relay.exit_policy_v6_summary : null;
-                    relay.bandwidthr = relay.bandwidth_rate ? hrBandwidth(relay.bandwidth_rate) : null;
-                    relay.bandwidthb = relay.bandwidth_burst ? hrBandwidth(relay.bandwidth_burst) : null;
-                    relay.obandwidth = relay.observed_bandwidth ? hrBandwidth(relay.observed_bandwidth) : null;
-                    relay.bandwidth = relay.advertised_bandwidth ? relay.advertised_bandwidth : null;
-                    relay.bandwidth_hr = relay.advertised_bandwidth ? hrBandwidth(relay.advertised_bandwidth) : null;
+                    relay.bandwidthr = (typeof relay.bandwidth_rate !== 'undefined') ? hrBandwidth(relay.bandwidth_rate) : null;
+                    relay.bandwidthb = (typeof relay.bandwidth_burst !== 'undefined') ? hrBandwidth(relay.bandwidth_burst) : null;
+                    relay.obandwidth = (typeof relay.observed_bandwidth !== 'undefined') ? hrBandwidth(relay.observed_bandwidth) : null;
+                    relay.bandwidth = (typeof relay.advertised_bandwidth !== 'undefined') ? relay.advertised_bandwidth : null;
+                    relay.bandwidth_hr = (typeof relay.advertised_bandwidth !== 'undefined') ? hrBandwidth(relay.advertised_bandwidth) : null;
                     relay.effective_family = relay.effective_family ? relay.effective_family : null;
                     relay.alleged_family = relay.alleged_family ? relay.alleged_family : null;
                     if (relay.is_bridge) {
    
    
More information about the tor-commits
mailing list