ocket8888 commented on a change in pull request #3662: TP: empty / duplicate
consistent hash query params for a ds need to be re…
URL: https://github.com/apache/trafficcontrol/pull/3662#discussion_r291246118
##########
File path: traffic_portal/app/src/common/api/DeliveryServiceRequestService.js
##########
@@ -26,6 +26,9 @@ var DeliveryServiceRequestService = function(Restangular,
$http, $q, locationUti
this.createDeliveryServiceRequest = function(dsRequest) {
var request = $q.defer();
+ // strip out any falsy values or duplicates from
consistentHashQueryParams
+ dsRequest.deliveryService.consistentHashQueryParams =
_.compact(Array.from(new
Set(dsRequest.deliveryService.consistentHashQueryParams)));
Review comment:
this looks fine (pending testing), but I _would_ like to point something out
as long as we're using ES6 features like `Set`, it'd be nice to also use
Array methods instead of underscore.
e.g.
```javascript
>> const test = ['test', null, 'quest', 'test'];
<- Array(4) [ "test", null, "quest", "test" ]
>> let result = _.compact(Array.from(new Set(test))); // instead of this
<- Array [ "test", "quest" ]
>> result = Array.from(new Set(test)).filter(i => i); //do this
<- Array [ "test", "quest" ]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services