rytm-webflow 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rytm-webflow",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "rytm webflow pack - ASwap, ShowUp",
5
5
  "main": "scripts/index.js",
6
6
  "scripts": {
@@ -302,15 +302,18 @@ class ASwapDispatcher extends EventDispatcher {
302
302
  */
303
303
  formSubmit(form) {
304
304
  const useCache = !form.classList.contains(this.noCacheClassName);
305
- const url = form.getAttribute("action");
305
+ let url = form.getAttribute("action");
306
306
  if (url.indexOf('://') < 0) {
307
307
  this.currentTrigger = form
308
- const method = form.getAttribute('method') ? form.getAttribute('method') : 'get'
308
+ const method = form.getAttribute('method') ? form.getAttribute('method').toLowerCase() : 'get'
309
309
  const formData = new FormData(form);
310
+ if (method == 'get') {
311
+ // for GET add data string to URL
312
+ const dataStr = new URLSearchParams(formData).toString();
313
+ const dataSep = url.indexOf('?') > -1 ? '&' : '?';
314
+ url = dataStr && method == 'get' ? (url + dataSep + dataStr) : url;
315
+ }
310
316
  this.submit(url, formData, method, false, useCache);
311
- // const dataStr = new URLSearchParams(formData).toString();
312
- // const requestUrl = method == 'get' ? (url + '?' + dataStr) : url;
313
- // this.submit(requestUrl, formData, method, false, useCache);
314
317
  }
315
318
  }
316
319
  /**
@@ -335,9 +338,7 @@ class ASwapDispatcher extends EventDispatcher {
335
338
  this.loadURL(url, formData, method, false);
336
339
  break;
337
340
  default:
338
- // GET
339
- const dataStr = new URLSearchParams(formData).toString();
340
- url = method == 'get' ? (url + '?' + dataStr) : url;
341
+ // GET / PUT / PATCH / DELETE
341
342
  let result = useCache ? this.getStoredResult(url) : null;
342
343
  if (result) {
343
344
  this.handleResult(result);