vkz/bemhtml-syntax

Regexp is broken after convert

Open

#28 建立於 2015年12月3日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)JavaScript (4 fork)github user discovery
bughelp wanted

倉庫指標

Star
 (10 star)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南