better detection of baseurl

I was using a path like this ```/packages/timelinejs/js/storyjs-embed.js```. Unfortunately, this didn't work because ```split("js/")``` found two ```js/``` and thus created an invalid path. The attached pull request worked for me.