vkz/bemhtml-syntax

Regexp is broken after convert

Open

#28 aperta il 3 dic 2015

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)JavaScript (4 fork)github user discovery
bughelp wanted

Metriche repository

Star
 (10 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Input file suggest-item_type_nav with BEMHTML:

block suggest-item, mod type nav {
    default: {
        var url = this.ctx.data[4];
        applyNext({_url: (url.match(/^\w[\w-]*:\/\//g) ? '' : 'http://') + url});
    }
}

Run bemhtml-syntax@0.0.25:

$ bemhtml-syntax -i suggest-item_type_nav

Actual:

block('suggest-item').mod('type', 'nav')(
    def()(function() {
        var url = this.ctx.data[4];
        return applyNext({
            _url: (url.match('^\w[\w-]*:\/\/' // regexp turned to string
                g) ? '' : 'http://') + url 
        });
    }))

Expected:

block('suggest-item').mod('type', 'nav')(
    def()(function() {
        var url = this.ctx.data[4];
        return applyNext({
            _url: (url.match(/^\w[\w-]*:\/\//g) ? '' : 'http://') + url
        });
    }))

Guida contributor