Q:

W3 total cache plugin cdn url not working with woo theme

I am currently trying to get W3 Total Cache to work on a wordpress website and noticed some rather weird behavior with the CDN url request being sent.
I am using cloudfront cdn and point it to CNAME (cdn.test.com) pointing to the cloudfront url.
Now all the images, css and javascript that are not part of the theme are rendering properly with the CDN CNAME url. 
example: http://cdn.test.com/wp-content/2015/01/image-150X150.jpg
http://cdn.test.com/wp-includes/base/css/style.css
http://cdn.tes.com/wp-includes/base/js/home.js

(May I also add that this also happens with the cloudfront url as well.)
But when it come to the css and javascript that are part of the woo theme it renders as follows.
http://cdn.test.com/http://example.com/wp-content/themes/test-theme/js/theme.js
http://cdn.test.com/http://example.com/wp-content/themes/test-theme/css/theme.css

I have taken this up with the theme developers and others concerned but very little has come out from them.
I have looked at various options like using preg_replace to match the occurrence of the weird url and replace it with an empty string.
This however did not work because i was probably using/calling the wrong add_action or add_filter from the reference documentation https://support.woothemes.com/hc/en-us/articles/203106877-Canvas-Hook-Filter-Reference and that of wordpress (I mean wp_head or wp_footer).
As you may have figured out I am not experienced with wordpress and I ask that you please help explain what is going on or wrong with this and possible ways i can resolve this matter.
Thanks for your help.

A:

Finally, traced and fix this issue with this code:
add_filter('w3tc_cdn_url', 'fix_host_in_cdn_url',10,3);
function fix_host_in_cdn_url($content) {
  $content = preg_replace("/(\/http?:\/\/[\da-z\.-])/", '', $content);
  return $content;
}

