<commit_before>/**
 * @license
 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at
 * http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at
 * http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at
 * http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at
 * http://polymer.github.io/PATENTS.txt
 */
import * as path from 'path';
import {FileRelativeUrl, ResolvedUrl} from 'polymer-analyzer';
import * as url from 'url';
import Uri from 'vscode-uri';

import constants from './constants';


/**
 * Produce a version of the URL provided with the given extension concatenated
 * to the path. Example:
 *     appendUrlPath('file:///something/something.html?ponies', '_omg.js')
 * Produces:
 *     'file:///something/something.html_omg.js?ponies'
 */
export function appendUrlPath(url_: string, extension: string): string {
  const uri = Uri.parse(url_);
  const newUri = Uri.from(Object.assign(uri, { path: `${uri.path}${extension}` });
  return newUri.toString();
}
/**
 * Given a string representing a relative path of some form, ensure a `./`
 * leader if it doesn't already start with dot-based path leader or a scheme
 * (like, you wouldn't want to change `file:///example.js` into
 * `./file:///example.js`)
 */
export function ensureLeadingDot<T extends string>(href: T): T {
  if (!Uri.parse(href).scheme &&
      !(href.startsWith('./') || href.startsWith('../'))) {
    return './' + href as T;
  }
  return href;
}

/**
 * Given a string representing a URL or path of some form, append a `/`
 * character if it doesn't already end with one.
 */
export function ensureTrailingSlash<T extends string>(href: T): T {
  return href.endsWith('/') ? href : (href + '/') as T;
}

/**<commit_msg>Added missing parenthesis.<commit_after>/**
 * @license
 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at
 * http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at
 * http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at
 * http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at
 * http://polymer.github.io/PATENTS.txt
 */
import * as path from 'path';
import {FileRelativeUrl, ResolvedUrl} from 'polymer-analyzer';
import * as url from 'url';
import Uri from 'vscode-uri';

import constants from './constants';


/**
 * Produce a version of the URL provided with the given extension concatenated
 * to the path. Example:
 *     appendUrlPath('file:///something/something.html?ponies', '_omg.js')
 * Produces:
 *     'file:///something/something.html_omg.js?ponies'
 */
export function appendUrlPath(url_: string, extension: string): string {
  const uri = Uri.parse(url_);
  const newUri =
      Uri.from(Object.assign(uri, {path: `${uri.path}${extension}`}));
  return newUri.toString();
}
/**
 * Given a string representing a relative path of some form, ensure a `./`
 * leader if it doesn't already start with dot-based path leader or a scheme
 * (like, you wouldn't want to change `file:///example.js` into
 * `./file:///example.js`)
 */
export function ensureLeadingDot<T extends string>(href: T): T {
  if (!Uri.parse(href).scheme &&
      !(href.startsWith('./') || href.startsWith('../'))) {
    return './' + href as T;
  }
  return href;
}

/**
 * Given a string representing a URL or path of some form, append a `/`
 * character if it doesn't already end with one.
 */
export function ensureTrailingSlash<T extends string>(href: T): T {
  return href.endsWith('/') ? href : (href + '/') as T;
}

/**
{'fraction_non_alphanumeric': 0.1390020366598778, 'fraction_numerical': 0.002036659877800407, 'mean_word_length': 3.68854415274463, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4871534', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1156, 'n_words': 428}