OverZealous / cdnizer

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

Add support for custom matchers #3

Closed magnusvk closed 10 years ago

magnusvk commented 10 years ago

We keep some URLs that we want to CDN-ize in custom data-attributes. To support that, we need to add a custom matcher. This adds support for that.

OverZealous commented 10 years ago

I'd like to see an example of your use case. It sounds like a good idea, but I can't accept this as is. It has numerous problems:

magnusvk commented 10 years ago

@OverZealous Thanks for getting back to me so quickly. I think I've addressed all of the issues you've raised in my additional commits. Sorry about the underscore confusion, that was just a brainfart on my part -- when I saw the _ I just assumed you were using that already, but lodash does the things I need and is already there as a dependency, so now I just use that.

Re: Example. I added one in the README. At Bonobos, we use this to dynamically resize our images through imgIX. The actual image src lives in a data-src attribute, then at runtime when we know what width we are displaying the image as, we request exactly that width. It's pretty nifty.

Please take another look and let me know if there's anything else you'd like me to address. Also, thanks for making this! :)

OverZealous commented 10 years ago

Awesome, looks great! Thanks for going through and adding this. That's a great use case, I hadn't even thought of that.

OverZealous commented 10 years ago

OK, everything has been updated and published to NPM, including an updated gulp-cdnizer, which isn't critical, but I like keeping the docs in sync.