here
using wrong slashes on Windows
#71
Closed
opened 4 years ago by soapdog
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Unfortunately functions and variables that generate paths such as
◊|here|
end up using\
instead of/
on Windows. This means that if you generate your website using Pollen on Windows you'll end up with wrong paths all over the place. It would be better if Pollen always used/
since webservers kinda expect that to be the path separator.Racket’s default policy is that “paths are created and manipulated for the current platform”. Furthermore, Pollen is not strictly a system for generating web pages. For these reasons, I’m not yet persuaded that it should adopt web-path conventions by default.
I understand, @mbutterick, no worries. I just built myself a little helper here to solve this when doing interpolation in HTML. Thanks.
If working on Windows you can add a utility function to replace backslashes with slashes.
It's surprising to me, though, that on Windows there seems to be no way to generate convert between Windows and Unix paths using only Racket’s path functions.
build-path/convention-type
simply refuses to generate a Unix path on a Windows system, even when building from plain strings.@otherjoel your
windows->web
function is exactly the same as the helper I built here. ❤️You can make a path for a different platform, but you have to make path elements that are compatible with the target by explicitly converting from byte strings On my Mac, I can’t do this:
But this works:
Handling paths as if they were strings is a little like mixing up
eq?
andequal?
— it seems to give good results, until it suddenly doesn’t. Likewise, be aware thatwindows->web
won’t behave correctly on all cases, even if it behaves correctly on some.