vkz/bemhtml-syntax

Regexp is broken after convert

Open

#28 opened on 2015年12月3日

GitHub で見る
 (3 comments) (0 reactions) (0 assignees)JavaScript (4 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (10 stars)
PR merge metrics
 (PR metrics pending)

説明

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
        });
    }))

コントリビューターガイド