WordPress.org

Making WordPress.org

Changeset 2116


Ignore:
Timestamp:
11/23/2015 04:08:42 PM (6 years ago)
Author:
ocean90
Message:

Trac: Preserve the char(s) before an @-mention.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r1995 r2116  
    9393        linkMentions: function() {
    9494            // See https://github.com/regexps/mentions-regex/blob/master/index.js#L21
    95             var mentionsRegEx = /(?:^|[^a-zA-Z0-9_@!@#$%&*])(?:(?:@|@)(?!\/))([a-zA-Z0-9/_.]{1,20})(?:\b(?!@|@)|$)/g;
     95            var mentionsRegEx = /(^|[^a-zA-Z0-9_@!@#$%&*])(?:(?:@|@)(?!\/))([a-zA-Z0-9/_.]{1,20})(?:\b(?!@|@)|$)/g;
    9696
    9797            $( 'div.change .comment, #ticket .description' ).each( function() {
    9898                $comment = $( this ).html();
    9999                if ( mentionsRegEx.test( $comment ) ) {
    100                     $comment = $comment.replace( mentionsRegEx, function( match, username ) {
     100                    $comment = $comment.replace( mentionsRegEx, function( match, pre, username ) {
    101101                        if ( -1 !== $.inArray( username, reservedTerms ) ) {
    102102                            return match;
     
    104104
    105105                        var meClass = ( username === wpTrac.currentUser ) ? ' me' : '';
    106                         return ' <a class="mention' + meClass + '" href="https://profiles.wordpress.org/' + username + '">@' + username + '</a>';
     106                        return pre + '<a class="mention' + meClass + '" href="https://profiles.wordpress.org/' + username + '">@' + username + '</a>';
    107107                    } );
    108108                    $( this ).html( $comment );
Note: See TracChangeset for help on using the changeset viewer.