How to specify default protocol #1639
-
It's a common pattern to not include protocol in your links and let the browser choose the protocol based on the current URL. That way, all links will have the E.I: Given a link like If the current URL is If the current URL is
However, this scheme does not appear to work with lychee. And I could not find any documentation how to configure lychee to behave like a browser. I need lychee to analyse the naked links. Any help in how to configure lychee to this end or pointers to where in lychee this could be implemented, is greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Yes, you're right, and I know about that behavior, which is commonly used in browsers as far as I'm aware. In order to do so, we'd have to "track" the origin of a link across the entire chain. We could introduce a lychee/lychee-lib/src/types/request.rs Lines 9 to 27 in d6bbf85 I guess it would be totally achievable, however, it might be quite some work to follow through. Namely, we support Markdown and Plaintext formats, and we also support local HTML files, for which there wouldn't be any kind of "parent" or source URL. So the field would be more like parent: Option<Url> or even parent: Option<Request> And when we build the request URL, we would have to check that source and take it into account. If you like, feel free to experiment with the code and see if it would be possible to add the functionality without too much hassle. |
Beta Was this translation helpful? Give feedback.
-
I think my problem is similar to this, so I'm commenting here. How can I check links to webpages, when I'm checking files on the filesystem, and the links to webpages are naked. example: <!-- index.html -->
<a href="//example.com">mylink</a> <!-- fails, is naked url -->
<a href="//developer.mozilla.org/en-US/docs/Web/CSS/@starting-style">@starting-style</a> <!-- excluded, as mail -->
<a href="file.html">myfile</a> <!-- works, is local file --> $ lychee . -v
[WARN ] Error creating request: InvalidPathToUri("//example.com")
[EXCLUDED] mailto://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style
[200] file:///<redacted>/file.html
🔍 2 Total (in 0s) ✅ 1 OK 🚫 0 Errors 👻 1 Excluded
$ lychee --version
lychee 0.18.1 |
Beta Was this translation helpful? Give feedback.
Yes, you're right, and I know about that behavior, which is commonly used in browsers as far as I'm aware.
At the moment, lychee doesn't support that.
In order to do so, we'd have to "track" the origin of a link across the entire chain. We could introduce a
parent
URL to a request here:lychee/lychee-lib/src/types/request.rs
Lines 9 to 27 in d6bbf85