<commit_before>/**
 * Utils.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

import { Element } from '@ephox/dom-globals';
import Tools from 'tinymce/core/api/util/Tools';
import Settings from '../api/Settings';

const getHref = (elm: Element) => {
  // Returns the real href value not the resolved a.href value
  const href = elm.getAttribute('data-mce-href');
  return href ? href : elm.getAttribute('href');
};

const toggleTargetRules = function (rel, isUnsafe) {
  const rules = ['noopener'];
  let newRel = rel ? rel.split(/\s+/) : [];

  const toString = function (rel) {
    return Tools.trim(rel.sort().join(' '));
  };

  const addTargetRules = function (rel) {
    rel = removeTargetRules(rel);
    return rel.length ? rel.concat(rules) : rules;
  };<commit_msg>AP-435: Use HTMLAnchorElement instead of Element for the type in getHref()<commit_after>/**
 * Utils.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

import { HTMLAnchorElement } from '@ephox/dom-globals';
import Tools from 'tinymce/core/api/util/Tools';
import Settings from '../api/Settings';

const getHref = (elm: HTMLAnchorElement): string => {
  // Returns the real href value not the resolved a.href value
  const href = elm.getAttribute('data-mce-href');
  return href ? href : elm.getAttribute('href');
};

const toggleTargetRules = function (rel, isUnsafe) {
  const rules = ['noopener'];
  let newRel = rel ? rel.split(/\s+/) : [];

  const toString = function (rel) {
    return Tools.trim(rel.sort().join(' '));
  };

  const addTargetRules = function (rel) {
    rel = removeTargetRules(rel);
    return rel.length ? rel.concat(rules) : rules;
  };
{'fraction_non_alphanumeric': 0.1521402784940691, 'fraction_numerical': 0.009798865394533264, 'mean_word_length': 3.743276283618582, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3854755', 'n_tokens_mistral': 646, 'n_tokens_neox': 623, 'n_words': 169}