<commit_before>"use strict";

module.exports = MarketListing;

const Regex = require('../../resources/regex.js');

const elRow = '.market_listing_row_link';
const elMarketName = '.market_listing_item_name';
const elGameName = '.market_listing_game_name';
const elItemImage = 'img.market_listing_item_img';
const elQuantity = '.market_listing_num_listings_qty';

const elNormalPrice = '.normal_price';
const elSalePrice = '.sale_price';

const defaultIconSize = '/62fx62f';

function MarketListing($) {
    let url = $(this).attr('href') || $(elRow).attr('href');

    this.market_name = $(elMarketName).text();
    this.market_hash_name = this._splitURL(url, 6);
    this.game_name = this.description = $(elGameName).text();

    this.appID = parseInt(this._splitURL(url, 5), 10);
    this.url = url;
    this.image = ($(elItemImage).attr('src')).replace(defaultIconSize, '');

    this.quantity = parseInt($(elQuantity).text(), 10);
    this.normal_price = parseFloat(($(elNormalPrice).eq(1).text()).replace('$', ''));
    this.sale_price = parseFloat(($(elSalePrice).text()).replace('$', ''));

    this.border_color = Regex.get(Regex.listings.borderColor, $(elItemImage).attr('style'), 2) || false;
}

MarketListing.prototype._splitURL = function(url, index) {
    return decodeURIComponent(url.split('/')[index]).toString('utf8');
}<commit_msg>Fix error when listing has no image<commit_after>"use strict";

module.exports = MarketListing;

const Regex = require('../../resources/regex.js');

const elRow = '.market_listing_row_link';
const elMarketName = '.market_listing_item_name';
const elGameName = '.market_listing_game_name';
const elItemImage = 'img.market_listing_item_img';
const elQuantity = '.market_listing_num_listings_qty';

const elNormalPrice = '.normal_price';
const elSalePrice = '.sale_price';

const defaultIconSize = '/62fx62f';

function MarketListing($) {
    let url = $(this).attr('href') || $(elRow).attr('href');

    this.market_name = $(elMarketName).text();
    this.market_hash_name = this._splitURL(url, 6);
    this.game_name = this.description = $(elGameName).text();

    this.appID = parseInt(this._splitURL(url, 5), 10);
    this.url = url;
    
    let image = $(elItemImage).attr('src');
    if(image) image = image.replace(defaultIconSize, '');
    this.image = image || null;

    this.quantity = parseInt($(elQuantity).text(), 10);
    this.normal_price = parseFloat(($(elNormalPrice).eq(1).text()).replace('$', ''));
    this.sale_price = parseFloat(($(elSalePrice).text()).replace('$', ''));

    this.border_color = Regex.get(Regex.listings.borderColor, $(elItemImage).attr('style'), 2) || false;
}

MarketListing.prototype._splitURL = function(url, index) {
    return decodeURIComponent(url.split('/')[index]).toString('utf8');
}
{'fraction_non_alphanumeric': 0.18194893923049263, 'fraction_numerical': 0.009349154980222941, 'mean_word_length': 5.154867256637168, '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': '5974403', 'n_tokens_mistral': 951, 'n_tokens_neox': 905, 'n_words': 153}