summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/navigation_utility.js
blob: 1579b225e44d16ba5e28ca7f6b956e536ba2e30b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { visitUrl } from './url_utility';

/**
 * Helper function that finds the href of the fiven selector and updates the location.
 *
 * @param  {String} selector
 */
export default function findAndFollowLink(selector) {
  const element = document.querySelector(selector);
  const link = element && element.getAttribute('href');

  if (link) {
    visitUrl(link);
  }
}