KSP-CKAN/CKAN — pull request #470 by pjf (2014-11-27 06:44:49+00:00)
Title: More aggressive escaping of URLs by NetKAN

For #464 (CKAN files would be generated with invalid URLs)

- We now aggressively escape all URLs from KerbalStuff
- Alas, we revert #459 (how file caching by URL is handled)

The reason for reverting #459 is that with how things currently are, two URLs which are the same (eg: `http://Example.com/' and `http//example.com/`) will result in the cache looking in two different locations, and *not* finding an already cached file. In the case of the NetKAN, we use the cache twice; once with the URL provided from KerbalStuff (which doesn't have the URL aggressively escaped) and again upon verifying the document (when we do have it aggressively escaped). Consequently, the file appears to "disappear" from the cache in between these two steps.

We *can* fix this in the NetKAN side of things, but as commented in #459, I'd rather we just provide a dead-simple, stand-alone, command-line wrapper around the cache's URL -> filename mapper. Programs written in C# can call our class natively. Those written in shell, perl, python, ruby, and other languages can just call our helper to do a cache look-up.

This means we get the best of both worlds; we never download a file when we've already got it, and external programs have a way of querying the cache without needing to worry about how C# normalises its URLs.