packages/basic-current-anchor/src/CurrentAnchor.js
function refresh(element) {
  const url = window.location.href;
  let match;
  if (element.areaLink) {
    // Match prefix
    let prefix = element.href;
    // If prefix doesn't end in slash, add a slash.
    // We want to avoid matching in the middle of a folder name.
    if (prefix.length < url.length && prefix.substr(-1) !== '/') {
      prefix += '/';
    }
    match = (url.substr(0, prefix.length) === prefix);
  } else {
    // Match whole path
    match = (url === element.href);
  }
  element.current = match;
}
function refresh(element) {
  const url = window.location.href;
  let match;
  if (element.areaLink) {
    // Match prefix
    let prefix = element.href;
    // If prefix doesn't end in slash, add a slash.
    // We want to avoid matching in the middle of a folder name.
    if (prefix.length < url.length && prefix.substr(-1) !== '/') {
      prefix += '/';
    }
    match = (url.substr(0, prefix.length) === prefix);
  } else {
    // Match whole path
    match = (url === element.href);
  }
  element.current = match;
}
function refresh ( element ) { const url = window . location . href ; let match ; if ( element . areaLink ) { // Match prefix let prefix = element . href ; // If prefix doesn't end in slash, add a slash. // We want to avoid matching in the middle of a folder name. if ( prefix . length < url . length && prefix . substr ( - 1 ) !== '/' ) { prefix += '/' ; } match = ( url . substr ( 0 , prefix . length ) === prefix ) ; } else { // Match whole path match = ( url === element . href ) ; } element . current = match ; }
Update the current status of the element based on the current location.
Update the current status of the element based on the current location .