From 6669b23d9aa8c6570841ebd660e205b087061d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 17 Sep 2020 23:11:04 -0400 Subject: [PATCH] feat: single href --- public/src/ajaxify.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index cdbd3db3b1..8bfa09d7d4 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -444,6 +444,8 @@ $(document).ready(function () { return; } + var $this = $(this); + var href = $this.attr('href'); var internalLink = utils.isInternalURI(this, window.location, config.relative_path); var process = function () { @@ -475,7 +477,7 @@ $(document).ready(function () { } }; - if ($(this).attr('data-ajaxify') === 'false') { + if ($this.attr('data-ajaxify') === 'false') { if (!internalLink) { return; } @@ -483,12 +485,12 @@ $(document).ready(function () { } // Default behaviour for rss feeds - if (internalLink && $(this).attr('href') && $(this).attr('href').endsWith('.rss')) { + if (internalLink && href && href.endsWith('.rss')) { return; } // Default behaviour for sitemap - if (internalLink && $(this).attr('href') && String(_self.pathname).startsWith(config.relative_path + '/sitemap') && $(this).attr('href').endsWith('.xml')) { + if (internalLink && href && String(_self.pathname).startsWith(config.relative_path + '/sitemap') && href.endsWith('.xml')) { return; } @@ -499,7 +501,7 @@ $(document).ready(function () { return; } - if (hrefEmpty(this.href) || this.protocol === 'javascript:' || $(this).attr('href') === '#') { + if (hrefEmpty(this.href) || this.protocol === 'javascript:' || href === '#' || href === '') { return e.preventDefault(); }