<commit_before>var Chat = function() {
    //this.members = {};
    //this.messages = [];
    this.state = this.buildState();
    this.colors = [
        'red',
        'blue',
        'green'
    ]
}

Chat.prototype.buildState = function() {
    var newState = {members: {}, messages: [], member_count: 0};
    return newState;
}

Chat.prototype.addMessage = function(conn, message) {
    var message = {
        user_id: conn.id,
        message: message,
        color: this.getMemberColor( conn.id )
    };

    this.state.messages.push( message );

    return message;
}

Chat.prototype.addMember = function(conn, username) {
    this.state.member_count += 1;

    var member = {
        id: conn.id,
        username: username, 
        status: 'connected',
        color: this.colors.shift()
    };
    this.state.members[conn.id] = member;

    return member;
}

Chat.prototype.getMemberColor = function(id) {
    return this.state.members[id].color;
}

Chat.prototype.getState = function(){
    return this.state;
}

exports.Chat = Chat;
<commit_msg>Add replace urls text to replace urls with proper links<commit_after>var Chat = function() {
    //this.members = {};
    //this.messages = [];
    this.state = this.buildState();
    this.colors = [
        'red',
        'blue',
        'green'
    ]
}

Chat.prototype.buildState = function() {
    var newState = {members: {}, messages: [], member_count: 0};
    return newState;
}

Chat.prototype.addMessage = function(conn, message) {
    var message = {
        user_id: conn.id,
        message: this.replaceUrls(message),
        color: this.getMemberColor( conn.id )
    };

    this.state.messages.push( message );

    return message;
}

Chat.prototype.addMember = function(conn, username) {
    this.state.member_count += 1;

    var member = {
        id: conn.id,
        username: username, 
        status: 'connected',
        color: this.colors.shift()
    };
    this.state.members[conn.id] = member;

    return member;
}

Chat.prototype.getMemberColor = function(id) {
    return this.state.members[id].color;
}

Chat.prototype.getState = function(){
    return this.state;
}

Chat.prototype.replaceUrls = function(message) {
  var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  return message.replace(exp,"<a target='_blank' href='$1'>$1</a>"); 
}

exports.Chat = Chat;

{'fraction_non_alphanumeric': 0.16394813885403597, 'fraction_numerical': 0.004182350480970306, 'mean_word_length': 2.602409638554217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4389703', 'n_tokens_mistral': 801, 'n_tokens_neox': 784, 'n_words': 150}