]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1694 from ArthurHoaro/fix/bulk-add-redirect-token
authorArthurHoaro <arthur@hoa.ro>
Tue, 26 Jan 2021 15:25:09 +0000 (16:25 +0100)
committerGitHub <noreply@github.com>
Tue, 26 Jan 2021 15:25:09 +0000 (16:25 +0100)
Fix: bulk add redirection with ending slash

1  2 
assets/common/js/shaare-batch.js

index 4a1fdb2ed928ac59962c7bded70554ab3631bf4f,3324193f9f00a1fc6cb32fb3112367b9d9342dac..6fc16faf1e732d4326411a3458087d9da2d3d5b1
@@@ -4,11 -4,7 +4,11 @@@ const sendBookmarkForm = (basePath, for
  
    const formData = new FormData();
    [...inputs].forEach((input) => {
 -    formData.append(input.getAttribute('name'), input.value);
 +    if (input.getAttribute('type') === 'checkbox') {
 +      formData.append(input.getAttribute('name'), input.checked);
 +    } else {
 +      formData.append(input.getAttribute('name'), input.value);
 +    }
    });
  
    return new Promise((resolve, reject) => {
@@@ -30,9 -26,9 +30,9 @@@
  const sendBookmarkDelete = (buttonElement, formElement) => (
    new Promise((resolve, reject) => {
      const xhr = new XMLHttpRequest();
 -    xhr.open('GET', buttonElement.href);
 +    xhr.open('GET', `${buttonElement.href}&source=batch`);
      xhr.onload = () => {
 -      if (xhr.status !== 200) {
 +      if (xhr.status !== 204) {
          alert(`An error occurred. Return code: ${xhr.status}`);
          reject();
        } else {
@@@ -104,7 -100,7 +104,7 @@@ const redirectIfEmptyBatch = (basePath
          });
  
          Promise.all(promises).then(() => {
-           window.location.href = basePath || '/';
+           window.location.href = `${basePath}/`;
          });
        });
      });