Skip to content

Useref doesn't parse block with no space in comments #40

Description

@mike1808

I am trying to parse the following html

<!-- build:js scripts/combined.concat.min.js-->
<!-- some comment -->
<script type="text/javascript" src="scripts/this.js"></script>

<script type="text/javascript" src="scripts/that.js"></script>
<!-- endbuild-->

As you can see there are no spaces after scripts/combined.concat.min.js and that's why the parsed html looks like this (the value of the "parsed" variable from src/index.js 178:7)

{
    "type": "js",
    "target": "scripts/combined.concat.min.js-->",
    "attbs": "<!-- some comment"
}

I found that the reason in the following part of the "regbuild" regular expression

var regbuild = /<!--\s*build:(\w+)(?:\(([^\)]+)\))?\s*([^\s]+)?\s*(?:(.*))?\s*-->/;

The attribute group is not lazy. Making it lazy solves this issue, however, there are tests that fail.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions