tactivos / grunt-htmlrefs

Replaces (or removes) references to non-optimized scripts or stylesheets on HTML files
27 stars 14 forks source link

Wrong way to handle build file path via HTTP #11

Open gockxml opened 11 years ago

gockxml commented 11 years ago

File path with http: prefix would get a wrong src, which is truncated.

<!-- build:js http://code.jquery.com/jquery.min.js -->
<script src="lib/jquery.min.js"></script>
<!-- endbuild -->

the result:

 <script type="text/javascript" src="http"></script>

As I dig into the code, I found the reason. It uses colon to concatenate file type and file path, then splits later.

sections[[build[1], key.toString().trim()].join(':')] = last = [];

Anyway, it is not a big problem. My suggestion is using :: instead of :. You can use whatever you want.

qcgm1978 commented 11 years ago

I have the same problem. The grunt module works awesome, but this bug puzzles me. Has it any hack for the problem?

gockxml commented 11 years ago

@qcgm1978 Haven't yet. If your case is not http/https sensitive, just ignore http/https prefix and use <!-- build:js //code.jquery.com/jquery.min.js -->, the browser can automatically complete the protocol in accord with current page. If you must assign the protocol, one way you can do is hacking the code in <your_project>/node_modules/grunt-htmlrefs/task/grunt-htmlrefs.js and replace : to :: at #Line105 and #Line129.

johnnyhalife commented 11 years ago

I'll have a look at this in the next few days.

On Fri, Aug 9, 2013 at 9:02 AM, Gock notifications@github.com wrote:

@qcgm1978 https://github.com/qcgm1978 Haven't yet. If your case is not http/https sensitive, just ignore http/https prefix and use , the browser can automatically complete the protocol in accord with current page. If you must assign the protocol, one way you can do is hacking the code in <your_project/node_modules/grunt-htmlrefs/task/grunt-htmlrefs.js and replace : to :: at #Line105https://github.com/tactivos/grunt-htmlrefs/blob/master/tasks/grunt-htmlrefs.js#L105and

Line129https://github.com/tactivos/grunt-htmlrefs/blob/master/tasks/grunt-htmlrefs.js#L129

.

— Reply to this email directly or view it on GitHubhttps://github.com/tactivos/grunt-htmlrefs/issues/11#issuecomment-22390048 .

qcgm1978 commented 11 years ago

Thank you very much. I will try you suggests. If the problem solves, the build process of my project would come to completion.

qcgm1978 commented 11 years ago

It works when grunt-htmlrefs.js modified as you describe. Thanks a lot.