Skip to content

Fix Windows file:// URL generation in log viewer#200

Merged
simonpcouch merged 2 commits into
tidyverse:mainfrom
smach:fix-windows-file-urls
Jan 14, 2026
Merged

Fix Windows file:// URL generation in log viewer#200
simonpcouch merged 2 commits into
tidyverse:mainfrom
smach:fix-windows-file-urls

Conversation

@smach

@smach smach commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

On Windows, normalizePath() returns backslash paths like D:\path\to\logs. The previous code created invalid URLs like file://D:\path\to\logs.

Claude Opus 4.5 says:
Valid Windows file URLs need:

  • Three slashes before the drive letter: file:///D:/...
  • Forward slashes in the path

Added path_to_file_url() helper that uses winslash="/" and adds the correct number of slashes per platform.

Fixes log viewer showing "no logs" on Windows reported in Issue 199

🤖 Code generated in large part by Claude Code

On Windows, normalizePath() returns backslash paths like D:\path\to\logs.
The previous code created invalid URLs like file://D:\path\to\logs.

Valid Windows file URLs need:
- Three slashes before the drive letter: file:///D:/...
- Forward slashes in the path

Added path_to_file_url() helper that uses winslash="/" and adds the
correct number of slashes per platform.

Fixes log viewer showing "no logs" on Windows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@smach

smach commented Dec 27, 2025

Copy link
Copy Markdown
Contributor Author

(Although this may end up causing other viewer problems now that I'm testing more myself. But I do think the issue is Windows file formats)

The previous commit fixed URL generation but broke loading logs because
file:///D:/path was being parsed back to /D:/path (invalid on Windows).

Added file_url_to_path() helper that strips the extra leading slash
on Windows when converting file:// URLs back to filesystem paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@smach smach marked this pull request as ready for review December 27, 2025 23:50
@smach

smach commented Dec 27, 2025

Copy link
Copy Markdown
Contributor Author

Possible fix?

@simonpcouch simonpcouch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks so much! This seems like a reasonable approach.

I'm currently taking a couple weeks to rest but will come back to this in the New Year. :)

@smach

smach commented Dec 29, 2025

Copy link
Copy Markdown
Contributor Author

Rest is awesome! Hope you have a couple of great holiday weeks. Absolutely no rush on this, only reason I brought this up now is because I'm staying home in some miserable winter weather playing with my extra Claude usage 😅 Happy New Year!

@simonpcouch

Copy link
Copy Markdown
Collaborator

Okay, back at it!

re:

Although this may end up causing other viewer problems now that I'm testing more myself. But I do think the issue is Windows file formats

Just to confirm, how does the code in this PR behave for you on Windows? What are the other viewer problems you're observing? It could be the case that my dev changes introduced several file-path issues on Windows and your changes just fix one of them.

@simonpcouch

Copy link
Copy Markdown
Collaborator

Thanks again!

@simonpcouch simonpcouch merged commit 4551bb2 into tidyverse:main Jan 14, 2026
15 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.

2 participants