From f452c34f78b7e37e1829a95b82741dd3f22698fd Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 22 Oct 2021 10:39:27 +0800 Subject: [PATCH] Fix context popup error --- web_src/js/features/contextpopup.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/contextpopup.js b/web_src/js/features/contextpopup.js index b97f77275aeb7..589369954a67b 100644 --- a/web_src/js/features/contextpopup.js +++ b/web_src/js/features/contextpopup.js @@ -10,7 +10,15 @@ export default function initContextPopups() { if ($(this).hasClass('ref-external-issue')) { return; } - const [index, _issues, repo, owner] = $(this).attr('href').replace(/[#?].*$/, '').split('/').reverse(); + + // some links were not generated by us and may lack the href attribute + const href = $(this).attr('href'); + if (!href) return; + // again, a simple check to make sure the link href is likely generated by us + const fields = href.replace(/[#?].*$/, '').split('/'); + if (fields.length !== 4) return; + + const [owner, repo, _issues, index] = fields; const el = document.createElement('div'); el.className = 'ui custom popup hidden';