<commit_before>import React from "react";
import PropTypes from "prop-types";

import { TokenLink } from "./";

/**
 * @typedef {Object} UrlProps
 * @property {string} url URL to use.
 * @property {string} token Token to use for tracking link.
 * @property {function()} resultClicked Function to run when the link has been clicked.
 */

/**
 * Renders a Url
 * @param {UrlProps} props
 * @returns {React.Component}
 */
const URL = ({ url, token, resultClicked }) =>
  <p className="sj-result-url">
    <TokenLink
      token={token}
      url={url}
      text={url}
      resultClicked={resultClicked}
    />
  </p>;

URL.propTypes = {
  url: PropTypes.string,
  token: PropTypes.string,
  resultClicked: PropTypes.func
};

export default URL;<commit_msg>url: render decoded url text<commit_after>import React from "react";
import PropTypes from "prop-types";

import { TokenLink } from "./";

/**
 * @typedef {Object} UrlProps
 * @property {string} url URL to use.
 * @property {string} token Token to use for tracking link.
 * @property {function()} resultClicked Function to run when the link has been clicked.
 */

/**
 * Renders a Url
 * @param {UrlProps} props
 * @returns {React.Component}
 */
const URL = ({ url, token, resultClicked }) => {
  let decodedText;
  try {
    decodedText = decodeURI(url);
  } catch (e) {
    // encoded url was malformed, fall back to displaying the encoded text
    decodedText = url;
  }
  return (
    <p className="sj-result-url">
      <TokenLink
        token={token}
        url={url}
        text={decodedText}
        resultClicked={resultClicked}
      />
    </p>
  );
};

URL.propTypes = {
  url: PropTypes.string,
  token: PropTypes.string,
  resultClicked: PropTypes.func
};

export default URL;
{'fraction_non_alphanumeric': 0.13501144164759726, 'fraction_numerical': 0.0, 'mean_word_length': 3.2144578313253014, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4854228', 'n_tokens_mistral': 549, 'n_tokens_neox': 552, 'n_words': 168}