<commit_before>'use strict';

var path = require('path');
var less = require('../thirdparty/less');

module.exports = fixUrls;
function fixUrls(getURL) {
  less.tree.URL.prototype.genCSS = function (env, output) {
    output.add("url(");

    var basedir = this.currentFileInfo.currentDirectory;
    var add = output.add;
    var buf = [];
    output.add = function (chunk) {
      buf.push(chunk);
    };
    this.value.genCSS(env, output);
    output.add = add;
    if (buf.length === 3 && buf[0] === buf[2] && buf[0] === '\'' || buf[0] === '"') {
      var fragment = buf[1].replace(/^[^#]*/, '');
      buf[1] = getURL(path.resolve(basedir, buf[1].split('#')[0]));
    }
    for (var i = 0; i < buf.length; i++) {
      output.add(buf[i]);
    }<commit_msg>Support urls that are not relative by leaving them un-changed<commit_after>'use strict';

var path = require('path');
var less = require('../thirdparty/less');

module.exports = fixUrls;
function fixUrls(getURL) {
  less.tree.URL.prototype.genCSS = function (env, output) {
    output.add("url(");

    var basedir = this.currentFileInfo.currentDirectory;
    var add = output.add;
    var buf = [];
    output.add = function (chunk) {
      buf.push(chunk);
    };
    this.value.genCSS(env, output);
    output.add = add;
    if (buf.length === 3 && buf[0] === buf[2] && (buf[0] === '\'' || buf[0] === '"')
        && buf[1].substr(0, 2) !== '//'
        && buf[1].substr(0, 5) !== 'http:'
        && buf[1].substr(0, 6) !== 'https:') {
      var fragment = buf[1].replace(/^[^#]*/, '');
      buf[1] = getURL(path.resolve(basedir, buf[1].split('#')[0]));
    }
    for (var i = 0; i < buf.length; i++) {
      output.add(buf[i]);
    }
{'fraction_non_alphanumeric': 0.2248381400824014, 'fraction_numerical': 0.017068864037669218, 'mean_word_length': 2.9260969976905313, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2174966', 'n_tokens_mistral': 617, 'n_tokens_neox': 606, 'n_words': 125}