+ // remove any URL paramters with empty values
+ // '&empty=&filled=value' => 'filled=value'
+ function clean_up_url_parameters(url) {
+ var url_params = new URLSearchParams(url);
+ var to_delete = []; // deleting inside loop would skip iterations
+ url_params.forEach(function (value, key) {
+ if (value === '') to_delete.push(key);
+ });
+ for (var i = 0; i < to_delete.length; i += 1) {
+ url_params.delete(to_delete[i]);
+ }
+ return url_params.toString();
+ }
+