Replace all occurrences of filename

Replace all occurrences of filename, not just the first one.

The approach used is faster than using regexp and safe against filenames containing regexp meta characters. 

Run [this](http://jsperf.com/replace-all-vs-split-join) in Chrome to see a performance comparison