From 232eefebbb831e0e21fc89ca4983b3daa8729522 Mon Sep 17 00:00:00 2001 From: AlexxNB Date: Wed, 9 Dec 2020 19:54:20 +0300 Subject: [PATCH] refactoring --- src/router.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/router.js b/src/router.js index fd39166..9334813 100644 --- a/src/router.js +++ b/src/router.js @@ -62,11 +62,13 @@ function aClickListener(go){ const a = e.target.closest('a[href]'); const i = a && getAttr(a,'tinro-ignore'); - let href = a && a.getAttribute('href'); - - if(!i && a && !/^\/\/|^https?:\/\//.test(href)) { - e.preventDefault(); - go(href.startsWith('/') ? href : a.href.replace(window.location.origin,'')); + if(!i && a){ + const href = a && a.getAttribute('href'); + + if(!/^\/\/|^https?:\/\//.test(href)) { + e.preventDefault(); + go(href.startsWith('/') ? href : a.href.replace(window.location.origin,'')); + } } }