<commit_before>import { Directive, Input } from '@angular/core';
import { Router } from '@angular/router';

function isString(value) {
  return typeof value === 'string' || value instanceof String;
}

function isInternalLink(link: string): boolean {
  if (link.indexOf('mailto') !== -1) {
    return false;
  } else if (link.indexOf('http') !== -1) {
    return true;
  }
  return true;
}

@Directive({
  selector: 'a[href]',
  host: {
    '(click)': 'onClick()'
  }
})
export class ContentLink {
  @Input() href: string;

  constructor(private router: Router) {
  }

  onClick(): boolean {
    if (isString(this.href) && isInternalLink(this.href)) {
      this.router.navigateByUrl(this.href.replace (/^[a-z]{4,5}\:\/{2}[a-z]{1,}\:[0-9]{1,4}.(.*)/, '$1'));
      return false;
    }
    return true;
  }
}<commit_msg>[BUGFIX] Fix external links<commit_after>import { Directive, Input } from '@angular/core';
import { Router } from '@angular/router';

function isString(value) {
  return typeof value === 'string' || value instanceof String;
}

function isInternalLink(link: string): boolean {
  if (link.indexOf('mailto') !== -1) {
    return false;
  } else if (link.indexOf('http') !== -1) {
    return false;
  }
  return true;
}

@Directive({
  selector: 'a[href]',
  host: {
    '(click)': 'onClick()'
  }
})
export class ContentLink {
  @Input() href: string;
  @Input() target: string;

  constructor(private router: Router) {
  }

  onClick(): boolean {
    if (this.target !== '_blank' && isString(this.href) && isInternalLink(this.href)) {
      this.router.navigateByUrl(this.href.replace (/^[a-z]{4,5}\:\/{2}[a-z]{1,}\:[0-9]{1,4}.(.*)/, '$1'));
      return false;
    }
    return true;
  }
}
{'fraction_non_alphanumeric': 0.2033997655334115, 'fraction_numerical': 0.012895662368112544, 'mean_word_length': 3.588709677419355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6867484', 'n_tokens_mistral': 612, 'n_tokens_neox': 600, 'n_words': 132}