Repository navigation
Only parse arguments as URLs when they look like URLs - #29
Merged
Merged
Conversation
Every argument went through url.Parse, with plain paths handled as URLs
without a scheme. That caused several problems:
- file:// URLs never worked: the original URL string was read from disk
instead of the path parsed out of it.
- Windows drive letters parsed as a scheme ("C:" became "c"), which
needed a special case.
- File names with a colon ("font:bold.ttf") parsed as a scheme, and
names with a percent sign ("100%zz.ttf") failed as invalid escapes.
Now only arguments containing "://" are parsed as URLs. file:// URLs are
converted to local paths, including drive letters and UNC hosts on
Windows, and everything else is treated as a local path. The
content-type handling moves into installData so local files and
downloads share it.
Fixes #26.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019v8ctg7o6tZH7zcRwizpF5
There was a problem hiding this comment.
🟡 Changes recommended
Mixed-case localhost authorities are handled incorrectly, causing valid local file URLs to fail.
1 open issue
What changed in this PR
This PR addresses #26 by separating local paths from URL handling, fixing file:// installation and avoiding URL parsing errors for ordinary filenames.
Changes:
- Parse arguments as URLs only when they contain
://. - Convert file URLs into platform-specific paths and share content handling through
installData. - Add tests for special filenames, file URL conversion, and unsupported schemes.
| File | Description |
|---|---|
install.go |
Separates path and URL handling, converts file URLs, and extracts shared installation logic. |
install_test.go |
Adds path-form and platform-specific file URL conversion tests. |
Review effort: Balanced
Host names are case-insensitive, but url.Parse keeps their case, so file://LOCALHOST/... was rejected on Unix and became a UNC path on Windows. Compare with strings.EqualFold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019v8ctg7o6tZH7zcRwizpF5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #26.
Every argument went through
url.Parse, and plain paths were handled as URLs with no scheme. That caused several bugs:file://URLs never worked: the original URL string was read from disk instead of the path parsed out of it (file:// URLs don't work for local paths on Windows #26).C:\fonts\x.ttfparsed with the schemec, which needed a special case.font:bold.ttfparsed with the schemefont, and100%zz.ttffailed as an invalid URL escape.Changes
://are parsed as URLs. Everything else is treated as a local path, with the existing wildcard handling.file://URLs are converted to local paths byfileURLToPath. On Windows that handles/C:/...paths and turnsfile://server/share/...into a UNC path. On other OSes, afile://URL with a host is rejected.installData, which local files and downloads share.Testing
TestPathForms:100%zz.ttf,font:bold.ttf(not on Windows), afile://URL for a temp file, and anftp://URL that must be rejected.TestFileURLToPath: conversion tables for Windows and for other OSes.file:///C:/.../My%20Fonts/FiraMono-Regular.ttf) now installs, as do a drive-letter path, a name containing%, and anhttpsdownload.GOOSset to windows, linux, darwin, freebsd and openbsd.🤖 Generated with Claude Code
https://claude.ai/code/session_019v8ctg7o6tZH7zcRwizpF5