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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

It looks like some tests are failing. Pro

checking it immediately

@josephadamsdev
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

Thanks for fixing this!

@josephadamsdev
Copy link
Copy Markdown
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
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 24, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [sharkdp/fd](https://github.com/sharkdp/fd) | minor | `v10.3.0` → `v10.4.2` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>sharkdp/fd (sharkdp/fd)</summary>

### [`v10.4.2`](https://github.com/sharkdp/fd/releases/tag/v10.4.2)

[Compare Source](sharkdp/fd@v10.4.1...v10.4.2)

#### Bugfixes

- Fixed performance regression due to `--ignore-contain`; see [#&#8203;1913](sharkdp/fd#1913) and [#&#8203;1914](sharkdp/fd#1914)

### [`v10.4.1`](https://github.com/sharkdp/fd/releases/tag/v10.4.1)

[Compare Source](sharkdp/fd@v10.4.0...v10.4.1)

This is just a re-release of 10.4.0 due to an issue with the 10.4.0 release.

### [`v10.4.0`](https://github.com/sharkdp/fd/releases/tag/v10.4.0)

[Compare Source](sharkdp/fd@v10.3.0...v10.4.0)

#### Features

- Add `--ignore-contain` option to ignore directories containing a named entry (e.g. to ignore [`CACHEDIR.TAG`](https://bford.info/cachedir/)); see [#&#8203;1727](sharkdp/fd#1727) ([@&#8203;fischman](https://github.com/fischman)).

#### Bugfixes

- Fix Windows hyperlink generation for paths with spaces. ([#&#8203;1872](sharkdp/fd#1872))

- `--print0` combined with `--exec` will now print a `\0` between the output of each entry. Note that if there are multiple instances
  of `--exec`, the `\0` will be between each *set* of commands, *not* between each individual command run. Fixes [#&#8203;1797](sharkdp/fd#1797).

- Several bugs were fixed by an update to the `ignore` library used for handling ignore rules
  - [#&#8203;1506](sharkdp/fd#1506)
  - [#&#8203;1667](sharkdp/fd#1667)
  - [#&#8203;1813](sharkdp/fd#1813)

#### Changes

- Minimum required rust version has been increased to 1.90.0. Notably, this means dropping fully support for intel Mac and Windows 7.
- Statically link the CRT for MSVC builds via Cargo config to avoid runtime DLL dependencies, see [#&#8203;1874](sharkdp/fd#1874) ([@&#8203;FidelSch](https://github.com/FidelSch))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My42MS43IiwidXBkYXRlZEluVmVyIjoiNDMuNjEuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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