Skip to content

Fix Windows hyperlinks for paths with spaces#1872

Merged
tmccombs merged 5 commits intosharkdp:masterfrom
josephadamsdev:fix-1843-windows-hyperlink-slash
Jan 16, 2026
Merged

Fix Windows hyperlinks for paths with spaces#1872
tmccombs merged 5 commits intosharkdp:masterfrom
josephadamsdev:fix-1843-windows-hyperlink-slash

Conversation

@josephadamsdev
Copy link
Contributor

Fixes #1843

This PR fixes hyperlink generation on Windows when file paths contain spaces or other characters that require percent-encoding.

Problem

On Windows, fd was generating file URLs like file://C:/test/hi%20there.txt (2 slashes) which don't work in Windows Terminal. Paths without spaces worked fine, but paths with spaces failed to open.

Solution

Changed the host() function for Windows to return "/" instead of "", generating RFC 3986 compliant URLs with three slashes: file:///C:/test/hi%20there.txt

Changes

  • Modified src/hyperlink.rs line 61 to return "/" for Windows
  • This matches the RFC 3986 file URL format: file:/// + drive path

Testing

The fix addresses the exact issue reported:

  • Before: file://C:/test/hi%20there.txt ❌ (broken)
  • After: file:///C:/test/hi%20there.txt ✅ (works)

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=105917501

Fixes sharkdp#1843

Changed the host() function for Windows to return '/' instead of ''
to generate RFC 3986 compliant file URLs with three slashes.

Before: file://C:/test/hi%20there.txt (broken)
After:  file:///C:/test/hi%20there.txt (works)

This fixes hyperlinks failing on Windows when file paths contain
spaces or other characters that require percent-encoding.
Copy link
Collaborator

@tmccombs tmccombs left a comment

Choose a reason for hiding this comment

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

It looks like some tests are failing. Probably the tests for hyperlinks need to be updated.

@josephadamsdev
Copy link
Contributor Author

It looks like some tests are failing. Pro

checking it immediately

@josephadamsdev
Copy link
Contributor Author

josephadamsdev commented Jan 15, 2026

Thanks for the heads-up @tmccombs updated the hyperlink test and pushed. CI ran successfully now.

Copy link
Collaborator

@tmccombs tmccombs left a comment

Choose a reason for hiding this comment

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

We should probably also add an entry to the changelog as well (sorry, I should have mentioned that in my previous review), but looks good.

@tmccombs
Copy link
Collaborator

Thanks for fixing this!

@josephadamsdev
Copy link
Contributor Author

We should probably also add an entry to the changelog as well (sorry, I should have mentioned that in my previous review), but looks good.

Good call @tmccombs I’ll add a changelog entry and push an update shortly. Thanks

@tmccombs tmccombs merged commit 1a37650 into sharkdp:master Jan 16, 2026
18 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.

[BUG] Hyperlinks fail on Windows when file path contains spaces

2 participants