From https://gist.github.com/jlong/2428561#file-uri-js