Skip to content
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

Support URL Encoded Anchors #1467

Closed
Silvenga opened this issue Jul 18, 2024 · 2 comments
Closed

Support URL Encoded Anchors #1467

Silvenga opened this issue Jul 18, 2024 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Silvenga
Copy link

Silvenga commented Jul 18, 2024

It appears that lychee assumes a different behavior from browsers regarding URL encoded anchors.

Given an anchor, such as #tangent%3A-kustomize, targeting the element id="tangent%3A-kustomize" lychee fails with Failed: Cannot find fragment. This appears to only occur with anchors that are URL encoded. Oddly, this only happens when processing local files, and not remote files:

.\lychee -v --include-fragments "dist\posts\helm-and-gitops\index.html"

✗ [ERR] file:///C:/Users/.../dist/posts/helm-and-gitops/index.html#tangent%3A-kustomize | Failed: Cannot find fragment
.\lychee -v --include-fragments https://silvenga.com/posts/helm-and-gitops

✔ [200] https://silvenga.com/#tangent%3A-kustomize

Although, I think that URL is incorrect - it should be https://silvenga.com/posts/helm-and-gitops#tangent%3A-kustomize.

Double checking with browsers, both Firefox and Chromium-based browsers appear to support URL encoded anchors.

@andreySadomovskiy
Copy link

Have the same issue, but with %e2%80%99 symbol.

@mre mre added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Sep 27, 2024
@mre
Copy link
Member

mre commented Sep 27, 2024

If someone wants to tackle this, here's what to do.

Bug Summary

Lychee fails to handle URL-encoded anchors in local files.

Reproduction Steps

  1. Create test.html:
cat << EOF > test.html
<html>
    <body>
        <a href="#tangent%3A-kustomize">test</a>
        <h1 id="tangent%3A-kustomize">Test Header</h1>
    </body>
</html>
EOF
  1. Run Lychee:
lychee -v --include-fragments test.html

Expected: Link is valid
Actual: Error - "Cannot find fragment"

Fix

Update lychee to properly decode URL-encoded anchors in local files.

autoantwort added a commit to autoantwort/lychee that referenced this issue Oct 18, 2024
autoantwort added a commit to autoantwort/lychee that referenced this issue Oct 26, 2024
@mre mre closed this as completed in 9801590 Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants