Commit eb016a2a authored by JC Brand's avatar JC Brand

try/catch clauses should contain as little code as possible

To avoid catching unrelated errors, which can mask other issues in the
code and make debugging more difficult
parent 831a9fa2
...@@ -84,10 +84,11 @@ u.isImageURL = url => { ...@@ -84,10 +84,11 @@ u.isImageURL = url => {
return regex ? regex.test(url) : u.isURLWithImageExtension(url); return regex ? regex.test(url) : u.isURLWithImageExtension(url);
} }
u.isImageDomainAllowed = url => { u.isImageDomainAllowed = url => {
const show_images_inline = api.settings.get('show_images_inline');
if (!Array.isArray(show_images_inline)) {
return true;
}
try { try {
const show_images_inline = api.settings.get('show_images_inline');
const is_domains_array = Array.isArray(show_images_inline);
if (!is_domains_array) return true;
const image_domain = getURI(url).domain(); const image_domain = getURI(url).domain();
return show_images_inline.includes(image_domain); return show_images_inline.includes(image_domain);
} catch (error) { } catch (error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment