Skip to content

Commit ab41069

Browse files
WezSieTatoCopilot
andauthored
fix: is real url
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6b31d80 commit ab41069

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

popup/pola.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,16 @@
8383
if (!url) {
8484
return false;
8585
}
86-
const u = url.toLowerCase();
87-
return !u.includes('example.pl') && !u.includes('example.com');
86+
try {
87+
const u = new URL(url);
88+
if (u.protocol !== 'http:' && u.protocol !== 'https:') {
89+
return false;
90+
}
91+
const host = u.hostname.toLowerCase();
92+
return host !== 'example.pl' && host !== 'example.com' && !host.endsWith('.example.pl') && !host.endsWith('.example.com');
93+
} catch {
94+
return false;
95+
}
8896
}
8997
restartAnimation(el) {
9098
el.classList.remove('animate');
@@ -194,12 +202,18 @@
194202
const img = document.createElement('img');
195203
img.src = brand.logotype_url;
196204
img.alt = brand.name || '';
197-
img.addEventListener('error', () => {
198-
tile.remove();
199-
if (grid.childElementCount === 0) {
200-
section.hidden = true;
201-
}
202-
});
205+
img.addEventListener('error', () => {
206+
207+
tile.remove();
208+
209+
if (grid.childElementCount === 0) {
210+
211+
section.hidden = true;
212+
213+
}
214+
215+
});
216+
203217
if (this.isRealUrl(brand.website_url)) {
204218
const a = document.createElement('a');
205219
a.href = brand.website_url;

0 commit comments

Comments
 (0)