Skip to content

Suppress false redirect warnings for URLs with fragments#113

Merged
becheran merged 3 commits intomasterfrom
copilot/fix-anchor-target-warnings
Dec 8, 2025
Merged

Suppress false redirect warnings for URLs with fragments#113
becheran merged 3 commits intomasterfrom
copilot/fix-anchor-target-warnings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 6, 2025

URLs with fragments (e.g., https://example.com/page#anchor) incorrectly trigger redirect warnings. Fragments are client-side only and never sent to servers, causing the response URL (without fragment) to mismatch the original URL (with fragment).

Changes

  • Modified URL comparison logic in check_redirect to compare URLs component-by-component (scheme, host, port, path, query) instead of full URL equality, effectively ignoring fragments
  • Added tests covering both no-warning case (fragment-only difference) and warning case (real redirect with fragment present)

Example

Before:

[Warn] https://example.com/page#anchor - Request was redirected to https://example.com/page

After:

[ OK ] https://example.com/page#anchor

Real redirects still produce warnings as expected.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • en.wikipedia.org
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)
    • Triggering command: ./target/release/mlc ./target/release/mlc /tmp/test_fragments.md ndor/bin/as n.o ssl/�� openssl-build/install/lib/cmake/OpenSSL/OpenSSLConfig.cmake ssl.d; \ fi s nclude -I s ons ssl/�� penssl-sys-ae0514d51d0b74da/out/openssl-build/install/include/openssl/modes.h as nfig/composer/vendor/bin/as clude -Iproviderbasename io_ssl.d.tmp sr/local/ssl" e (dns block)
    • Triggering command: ./target/release/mlc ./target/release/mlc /tmp/test_fragments.md -I ons -lib�� 4d51d0b74da/out/openssl-build/install/include/openssl/pemerr.h enssl-build/install/lib/engines-3" /x86_64-linux-gnu/13/cc1 crypto/aes/aesni/home/REDACTED/work/mlc/mlc/target/release/build/native-tls-129fac7a7e83831a/build-v providers/implementations/kem/li644 sr/local/ssl" e ome/�� penssl-sys-ae0514d51d0b74da/out/openssl-build/install/include/openssl/bn.h /include/prov /snap/bin/as crypto/bn/rsaz-abash -I /usr/bin/as ib-der_wrap_gen.o (dns block)
  • google.de
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)
  • slashdot.org
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)
  • www.example.com
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)
  • www.google.com
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)
  • www.google.de
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)
  • www.mozilla.org
    • Triggering command: /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 /home/REDACTED/work/mlc/mlc/target/debug/deps/end_to_end-c67ddac374098736 lib --emit=dep-info,metadata,link 64-REDACTED-linux-gnu/bin/rust-lld embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg cfg(feature, values()) -C --gd�� /debug/build/ope/home/REDACTED/work/mlc/mlc/target/debug/build/getrandom-830a0a00e7afa51e/build_sccc --noexecstack lib/rustlib/x86_64-REDACTED-linux-gnu/bin/gcc-ld/ld.lld -der_rsa_sig.d >cc ssl-build/instal-Wl,--version-script=/tmp/rustcTEYk1X/list /usr/local/sbin/-Wl,--no-undefined-version lib/rustlib/x86_-m64 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Anchor targets lead to reported warnings</issue_title>
<issue_description>Describe the bug

The mlc check reports warnings like this:

Warning: https://aarnott.github.io/Nerdbank.MessagePack/docs/type-shapes.html#witness-classes. Request was redirected to https://aarnott.github.io/Nerdbank.MessagePack/docs/type-shapes.html

The only difference here is the lack of an #anchor at the end of the URL. But in fact a server doesn't redirect from one to the other, because the server never sees the #fragment portion of a URL. I think that the mlc tool is checking in the HTTP response for a header that discloses which URL the server ultimately returned, or maybe an API that retrieves the actual request URI of the last page after redirects. In either case, the #fragment will always be missing. But that doesn't mean it redirected. And in this case, I believe it didn't.

Expected behavior

Can the mlc tool suppress warnings when the 'redirect' is the same URL but without the #fragment?

Additional context

See also #31, which discusses supporting #fragments more fully. But I think that's likely a far more expensive task than simply suppressing a warning in this case.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 6, 2025 21:11
Co-authored-by: becheran <22472855+becheran@users.noreply.github.com>
Co-authored-by: becheran <22472855+becheran@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix anchor targets to resolve reported warnings Suppress false redirect warnings for URLs with fragments Dec 6, 2025
Copilot AI requested a review from becheran December 6, 2025 21:22
Copy link
Copy Markdown
Owner

@becheran becheran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@becheran becheran marked this pull request as ready for review December 8, 2025 21:03
@becheran becheran merged commit 6550848 into master Dec 8, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anchor targets lead to reported warnings

2 participants