-/*!
- * Serialize all form data into a SearchParams string
- * (c) 2020 Chris Ferdinandi, MIT License, https://gomakethings.com
- * @param {Node} form The form to serialize
- * @return {String} The serialized form data
- */
-export function serialize_form(form) {
- var arr = [];
- Array.prototype.slice.call(form.elements).forEach(function (field) {
- if (!field.name || field.disabled || ['file', 'reset', 'submit', 'button'].indexOf(field.type) > -1) return;
- // if (field.type === 'select-multiple') {
- // Array.prototype.slice.call(field.options).forEach(function (option) {
- // if (!option.selected) return;
- // arr.push(encodeURIComponent(field.name) + '=' + encodeURIComponent(option.value));
- // });
- // return;
- // }
- if (['checkbox', 'radio'].indexOf(field.type) >-1 && !field.checked) return;
- if (typeof(field.value) === 'undefined') return;
- arr.push(encodeURIComponent(field.name) + '=' + encodeURIComponent(field.value));
- });
- return arr.join('&');
-};
-
-
-// remove any URL paramters with empty values
-// '&empty=&filled=value' => 'filled=value'
-export 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]);
+function extend_parameters(params, params2) {
+ var param_names = Object.keys(params2);
+ for (var i = 0; i < param_names.length; i += 1) {
+ params[param_names[i]] = params2[param_names[i]];