OverZealous / cdnizer

Node module for replacing local links with CDN links, includes fallbacks and customization
MIT License
52 stars 24 forks source link

Matchers do not find elements that are split over more than one line. #8

Closed ntdaley closed 9 years ago

ntdaley commented 9 years ago

I encountered this with a css link, but I presume the same would apply for matching other urls.

For readability I had the link spread over two lines.

        <link rel="stylesheet" type="text/css"
              href="/vendor/ng-grid/ng-grid.min.css"/>

Because the href and <link were not on the same line, it failed to match the url.

When I changed this to one line:

        <link rel="stylesheet" type="text/css" href="/vendor/ng-grid/ng-grid.min.css"/>

it did match the url.

I don't need to split the tag over two lines (it was needed before I used this plugin when I was hardcoding long CDN URLs). But, it's something that should probably be fixed or documented so that it doesn't catch other people out.

OverZealous commented 9 years ago

@ntdaley Thanks for reporting this. I'll see how much work it is fixing the regexes, multiline matching is often a pain, but if I remember correctly, replacing /./ with /\s\S/ usually suffices.

OverZealous commented 9 years ago

Fixed in 08b3c1ca5323850e936272647c748469f9a2dd76 and pushed release 1.1.0 with fix included.