mirage / ocaml-crunch

Convert a filesystem into a static OCaml module
Other
74 stars 21 forks source link

Inconsistent file naming between Linux and Windows #57

Closed MisterDA closed 2 years ago

MisterDA commented 2 years ago

ocaml-crunch uses Filename.concat which uses Filename.dir_sep, so suppose that I have css/style.css, on Linux I can retrieve it from the crunch-generated module with "css/style.css" or "/css/style.css", but on Windows it's "css\\style.css" or "/css\\style.css" which is slightly inconsistent (this line). Should it always use Filename.dir_sep (to have "\\css\\style.css" for the second option) or always forward slashes?

My use-case is that I was bundling static assets in my executable which contains a web server. Urls such as http://localhost/css/style.css return 404 on Windows when simply forwarded to crunch because of the string comparison failure. If we go with the OS native file separators, this would require to possibly rewrite the url path to accommodate crunch view of the world.