Skip to content

Fix TypeError of stripIndent when use invalid use of octal escape sequences in template strings #210

@seongwon-kang

Description

@seongwon-kang

Currently this code will give an TypeError.

stripIndent`
    \4
`

Result is:

/home/vagrant/test/node_modules/common-tags/lib/stripIndentTransformer/stripIndentTransformer.js:20
        var match = endResult.match(/^[^\S\n]*(?=\S)/gm);
                              ^

TypeError: Cannot read property 'match' of undefined
    at Object.onEndResult (/home/vagrant/test/node_modules/common-tags/lib/stripIndentTransformer/stripIndentTransformer.js:20:31)
    at cb (/home/vagrant/test/node_modules/common-tags/lib/TemplateTag/TemplateTag.js:161:50)
    at Array.reduce (<anonymous>)
    at TemplateTag.transformEndResult (/home/vagrant/test/node_modules/common-tags/lib/TemplateTag/TemplateTag.js:163:32)
    at TemplateTag.tag (/home/vagrant/test/node_modules/common-tags/lib/TemplateTag/TemplateTag.js:54:20)

Because of SyntaxError was raised in template string, and TemplateTag.tag will get undefined string.

SyntaxError: Octal escape sequences are not allowed in template strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions