OverZealous / cdnizer

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

Does cdnizer support angular ng-src? #18

Closed martinmicunda closed 9 years ago

martinmicunda commented 9 years ago

Hi,

I have something like this in my app but it doesn't seems cdnizer replace path when I am using ng-src. Does cdnizer support ng-src? Thanks

<img ng-src="../../images/{{::employee.avatar}}" >
OverZealous commented 9 years ago

No, but you can add your own custom matchers. Look at lib/util.js for example matchers.

martinmicunda commented 9 years ago

@OverZealous

I tried use follow matcher:

matchers: [/(<img\s.*?data-src=["'])(.+?)(["'].*?>)/gi]

with this example:

<img ng-src="../../images/{{::employee.avatar}}" >

but it doesn't work because cdnizer doesn't find any fileInfo see your index.js.

Basically ../../images/{{::employee.avatar}} is not valid url address for cdnizer so it never replace this url (Angular add employee.avatar to url during bootstrapping). Is there any way that cdnizer can replace this url even in cases that fileInfo is undefined?

OverZealous commented 9 years ago

You have to specify the file regexes yourself. You need a pattern that matches your angular pattern.

A better option, probably, would be to move the logic into an angular directive or a filter, and have that use the right path, rather than try to match relative paths. Dynamic content isn't exactly the intended use for cdnizer.