[BUG] /insights generates invalid file:// URL on Windows with non-ASCII username

Resolved 💬 2 comments Opened Jun 8, 2026 by wpraiz Closed Jun 8, 2026

Summary

The /insights command outputs a file:// URL that is not RFC 8089 compliant on Windows, making the link non-functional — especially when the Windows username contains non-ASCII characters (accented letters, etc.).

Environment

  • OS: Windows 11 Pro 10.0.22631
  • Claude Code version: 2.1.168
  • Username: Contains non-ASCII characters (e.g. accented letters like é U+00E9 and Í U+00CD)
  • USERPROFILE: C:\Users\[username-with-accents]

Current (broken) output

Report URL: file://C:\Users\[username-with-accents]\.claude\usage-data\report-2026-06-08-062656.html

Expected output

file:///C:/Users/[username-with-accents-percent-encoded]/.claude/usage-data/report-2026-06-08-062656.html

Root cause (test evidence)

The URL is constructed by manually concatenating "file://" + windowsPath instead of using Node.js's url.pathToFileURL().

Test results:

| Check | Result |
|---|---|
| Slashes | file:// (2) → should be file:/// (3) |
| Path separator | Windows \ → should be / |
| Non-ASCII encoding | Raw accented chars → should be percent-encoded (e.g. %C3%A9) |
| Node.js url.pathToFileURL() output | ✅ file:///C:/Users/[encoded-username]/.claude/... |
| Browser host interpretation | The current URL causes C:\Users\[username] to be treated as the hostname, making the link dead |

Node.js validation:

const { pathToFileURL } = require('url');
pathToFileURL('C:\Users\[username-with-accents]\.claude\usage-data\report.html').href
// => "file:///C:/Users/[percent-encoded-username]/.claude/usage-data/report.html"

Impact

Affects any Windows user whose USERPROFILE path contains:

  • Non-ASCII/accented characters in the username (common for Brazilian, French, Spanish, Portuguese, Eastern European users)
  • The clickable file:// link in the terminal is broken — users cannot open the HTML report directly

Suggested fix

Replace the manual "file://" + reportPath string construction with:

import { pathToFileURL } from 'url';
const reportUrl = pathToFileURL(reportPath).href;

Related issues

  • #26946 — Bash tool fails when username contains a single quote
  • #29538 — Permission denied when username contains a space
  • #24366 — Crash with Unicode emoji in username

These are part of a pattern of Windows non-ASCII username handling issues.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗