OverZealous / cdnizer

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

add exclusions for absolute URLs #35

Closed thescientist13 closed 4 years ago

thescientist13 commented 5 years ago

resolves #21 by adding exceptions for paths that wouldn't need cdnizing, like:

OverZealous commented 4 years ago

Thanks for taking a look at this. As you can probably guess, I haven't really been maintaining this repo for a while now.

I think this is an interesting idea, but I have a couple requests:

  1. It should be optional, and not enabled by default. It might be weird, but it's already something that can be fixed with tighter Regexes, and there's always the possibility someone wants to swap absolute URLs with a different one. It also means I don't have to release this as a major version.
  2. The protocol check should include the colon (':'), I'll make a note inline in the code about this.
  3. Could you squash your commits down if you make the above changes?
thescientist13 commented 4 years ago

Thanks for taking a look and happy to make the suggested changes.

but it's already something that can be fixed with tighter Regexes

fair point, but happy that this can be considered a feature of the tool 😄

regarding this part

It should be optional, and not enabled by default

To implement that, would you like it so the user just passes something like

processInput({
  files: ['**/*.js', '**/*.png', '**/*.css'],
  defaultCDNBase: '//examplecdn/',
  preserveAbsolute: true
}, 'index-exclusions.html', 'index-exclusions.html');

and then the tool would only enable that check if the flag is in place?

var cdnTemplate = preserveAbsolute && excludeCdnPrefix 
  ? '<%= filepath %>' 
  : fileInfo.cdn || opts.defaultCDN;

I can update the README as well if the above behavior documented.

OverZealous commented 4 years ago

Yeah, exactly! And if you would update the README, that would be great, too. Thanks a bunch!

thescientist13 commented 4 years ago

@OverZealous Done! I'll squash once everything looks good to you. 👍

thescientist13 commented 4 years ago

@OverZealous Squashed 🔨

OverZealous commented 4 years ago

Published as v3.1.0