Skip to content

Commit

Permalink
feat: add logic to capture target from wrapping anchor tag
Browse files Browse the repository at this point in the history
  • Loading branch information
shsteimer committed Apr 8, 2024
1 parent f68b05e commit 2a733b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ const urlSanitizers = {
path: () => window.location.href.replace(/\?.*$/, ''),
};

const targetselector = (element) => {
let value = element.getAttribute('data-rum-target') || element.getAttribute('href')
const getTargetValue = (element) => element.getAttribute('data-rum-target') || element.getAttribute('href')
|| element.currentSrc || element.getAttribute('src') || element.dataset.action || element.action;

const targetselector = (element) => {
let value = getTargetValue(element);
if (!value && element.tagName !== 'A' && element.closest('a')) {
value = getTargetValue(element.closest('a'));
}
if (value && !value.startsWith('https://')) {
// resolve relative links
value = new URL(value, window.location).href;
Expand Down

0 comments on commit 2a733b3

Please sign in to comment.