-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter --base does not work on windows #1454
Comments
Hum, no idea why. I don't have a Windows machine to test this. Have you tried absolute paths as described on the page you linked? lychee --base file:///C:/my/folder/public ./public Apart from that, I think we need a better path handling crate, because we manually concatenate some of those paths and there are many edge-cases like yours. |
Related windows path bug: #972 |
Hey, thanks for getting back to me. Yeah, I did try with an absolute path and I experienced the same behavior. I attempted with both windows style \ paths and linux style / paths: lychee --base file:///C:/my/folder/public ./public My results were still:
|
Since I have a Windows device I wouldn't mind looking into the behavior myself if you could help point me to the file in the repo where the path handling is defined. |
Sure, that would be nice. I think the bug is somewhere here: lychee/lychee-lib/src/utils/path.rs Lines 43 to 70 in 4340fcb
|
Have something to report. Will put in a PR once I finalize, but the bug is caused by the behavior of
A relative URL in an HTML document starts with '/', which is how an absolute URL in a file system path starts. So when you provide a relative url like "/style.css" in your HTML file, Path::join sees this as an absolute filepath and discards the parent directory. |
Seems like a fix for this would be to prepend relative URLs with a period before trying to join them to a file system path. |
Identified another bug while investigating this as well. No time to write about it now as I have to go to the office now, but will follow up later with details. |
Right! I fell into this trap a few times by now. It's kind of a sharp edge of the standard library. Your fix makes sense to me. Thankful for a pull request if you find the time. 😃 |
Actually, I found a ton of windows bugs when I ran the test suite. Might take me a while to work through them to the point where I can write a proper test for the issue that I found. |
Ouch. Sorry to hear that and thankful for any support. |
If it makes the process easier, you could create separate issues for each one. But only if you think it's useful. |
Yeah, probably will. Most of the issues are related to windows filepath handling. For example, the test suites are failing because the tests are assuming that tempdir will return a unix style path, but on windows the path starts with c:/, which gets picked up by reqwest as an invalid scheme. |
@toadslop, we made a few path-related changes in the latest lychee versions. If possible, can you double-check what the current status is on Windows? A list of open issues would be nice. 😊 |
Assume I have a website in folder /my/folder/public. My website has many relative urls.
If I cd into /my/folder and run
lychee --base ./public ./public
. On Linux, this works -- ./public is joined to the working directory and the relative urls and produced correctly and all of the links work where they should.On Windows, this is the output:
It looks like on Windows Lychee is discarding the working directory instead of prepending it.
I also noticed when I checked the Windows documentation for the file protocal, the output looked a bit different than what Lychee rendered as well. You can check the examples on this page to see what I'm talking about.
The text was updated successfully, but these errors were encountered: