ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
738 stars 134 forks source link

Replace `file://` URLs with relative URLs #239

Closed toonn closed 6 years ago

toonn commented 6 years ago

When serving with --local, replace file:// URLs in files that are served from disk with relative file/ URLs.

Fix #236

Haven't been able to test this because of problems with zlib.h not being found even though there's multiple on my system (arch linux).

Decided to open the PR already anyway for feedback. I'm not sure about the performance implications of readFile and the literal string replacement I"m doing currently, a more proper way would be to parse URLs from the file and replace them with showURL True applied to them.

ndmitchell commented 6 years ago

Let's not worry about performance - it only gets called with --local so it really shouldn't be munging huge files.

I tested your code, and made a few changes to get it working, some of which were Windows only (there's a bug in the Haddock file:// links) and other issues as well. With all that, it seems to work nicely.