<commit_before>/* @flow */
"use strict";

// TODO: Use `URL` class, see http://nodejs.org/api/url.html#url_class_url
const parse = require("url").parse; // eslint-disable-line node/no-deprecated-api

/**
 * Get unit from value node
 *
 * Returns `null` if the unit is not found.
 */
module.exports = function(urlString /*: string*/) /*: ?string*/ {
  const url = parse(urlString);
  const protocol = url.protocol;<commit_msg>Replace Node.js legacy API for URL parsing. Fixes #3803 (#4024)<commit_after>/* @flow */
"use strict";

const { URL } = require("url");

/**
 * Get unit from value node
 *
 * Returns `null` if the unit is not found.
 */
module.exports = function(urlString /*: string*/) /*: ?string*/ {
  let protocol = null;

  try {
    protocol = new URL(urlString).protocol;
  } catch (err) {
    return null;
  }
{'fraction_non_alphanumeric': 0.1684848484848485, 'fraction_numerical': 0.009696969696969697, 'mean_word_length': 3.393617021276596, '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': '6513618', 'n_tokens_mistral': 277, 'n_tokens_neox': 268, 'n_words': 81}