Skip to content

Commit 842bcda

Browse files
authored
Merge pull request #1720 from Shadow243/fixed-unsubscribe-subscribe-error
fix(frontend): exclude external domains from internal navigation
2 parents 94fa7e5 + fa0e03b commit 842bcda

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

modules/core/navigation/navigation.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,24 @@ window.addEventListener('load', function() {
4040

4141

4242
$(document).on('click', '.cypht-layout a', function(event) {
43-
if ($(this).attr('href') !== "#" && $(this).attr('target') !== '_blank' && !$(this).data('external')) {
43+
const href = $(this).attr('href');
44+
const target = $(this).attr('target');
45+
const isExternal = $(this).data('external');
46+
47+
const isExternalDomain = href && (
48+
href.startsWith('http://') ||
49+
href.startsWith('https://') ||
50+
href.startsWith('//')
51+
) && !href.includes(window.location.hostname);
52+
53+
if (href !== "#" && target !== '_blank' && !isExternal && !isExternalDomain) {
4454
event.preventDefault();
4555
const currentUrl = new URL(window.location.href);
4656
const currentPage = currentUrl.searchParams.toString();
47-
const target = new URLSearchParams($(this).attr('href').split('?')[1]);
48-
if (currentPage !== target.toString()) {
57+
const targetParams = new URLSearchParams(href.split('?')[1]);
58+
if (currentPage !== targetParams.toString()) {
4959
Hm_Ajax.abort_all_requests();
50-
navigate(autoAppendParamsForNavigation($(this).attr('href')));
60+
navigate(autoAppendParamsForNavigation(href));
5161
}
5262
}
5363
});

0 commit comments

Comments
 (0)