Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle fixing of multiple different instances of insecure content #139

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/js/gutenberg.js
Expand Up @@ -43,7 +43,7 @@
character: 's',
},
});
}, []);

Check warning on line 46 in src/js/gutenberg.js

View workflow job for this annotation

GitHub Actions / eslint

React Hook useEffect has missing dependencies: 'registerShortcut' and 'unregisterShortcut'. Either include them or remove the dependency array

useShortcut(newSaveShortcutId, (event) => {
event.preventDefault();
Expand Down Expand Up @@ -124,13 +124,19 @@
if (data === true) {
jQuery(this).nextAll('.js-icw-fixed').show();
replaceContent(url);
// The "check" data has to be removed because otherwise it will always return the URL for the first replaced URL.
// Alternatively "const url = jQuery(clickedButton).data('check');" can be changed to "const url = clickedButton.dataset.check;".
jQuery(this).removeData('check');
} else {
// show the error
jQuery(this).nextAll('.js-icw-error').show();
throw new Error('No https equivalent found.');
}

// The instance of the clicked button will have been lost when the timeout happens, so an instance needs to be kept.
const clickedButton = e.currentTarget;
setTimeout(function () {
jQuery(clickedButton).nextAll('.js-icw-fixed').hide();
gutenbergCheck(e);
}, 1000);
},
Expand Down Expand Up @@ -169,6 +175,9 @@
'js-icw-is-insecure'
);
}

// The "check" data has to be removed because otherwise it will always return the URL for the first highlighted URL.
jQuery(this).removeData('check');
}
});
});