lib.Uri: Treat paths starting with ~" specially #48

Merged
Jan Lindemann merged 1 commit from jan/fix/20260722-lib-uri-treat-paths-starting-with-specially into master 2026-07-22 11:48:42 +02:00 AGit

lib.Uri: Treat paths starting with "~" specially

An Uri instance constructed from "~/some/path" returns "file://~/some/path" as the .full property, i.e. with the "~" in the authority part. That's not accurate and doesn't make the intended sense in an URL context, see RFC 8089:

Common UNIX shells such as the Bourne-Again SHell (bash) and Z SHell (zsh) provide a function known as "tilde expansion" [Bash-Tilde] or "filename expansion" [Zsh-Tilde], where a path that begins with a tilde character "~" can be expanded out to a special directory name. No such facility exists using the file URI scheme; a tilde in a file URI is always just a tilde.

The "fix" introduced by this commit makes .full return the path without file:// prepended. That's conservative. It could also chose to expand the tilde, which is arguably cleaner. To be introduced by a later change after this commit has seen more coverage.

#### lib.Uri: Treat paths starting with "~" specially An Uri instance constructed from "`~/some/path`" returns "`file://~/some/path`" as the .full property, i.e. with the "`~`" in the authority part. That's not accurate and doesn't make the intended sense in an URL context, see RFC 8089: Common UNIX shells such as the Bourne-Again SHell (bash) and Z SHell (zsh) provide a function known as "tilde expansion" [Bash-Tilde] or "filename expansion" [Zsh-Tilde], where a path that begins with a tilde character "`~`" can be expanded out to a special directory name. No such facility exists using the file URI scheme; a tilde in a file URI is always just a tilde. The "fix" introduced by this commit makes .full return the path without `file://` prepended. That's conservative. It could also chose to expand the tilde, which is arguably cleaner. To be introduced by a later change after this commit has seen more coverage.
lib.Uri: Treat paths starting with "~" specially
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 3m50s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 3m51s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m50s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m10s
CI / Packaging test (push) Successful in 0s
96409e50f7
An Uri instance constructed from "~/some/path" returns
"file://~/some/path" as the .full property, i.e. with the "~" in the
authority part. That's not accurate and doesn't make the intended
sense in an URL context, see RFC 8089:

  Common UNIX shells such as the Bourne-Again SHell (bash) and Z
  SHell (zsh) provide a function known as "tilde expansion"
  [Bash-Tilde] or "filename expansion" [Zsh-Tilde], where a path
  that begins with a tilde character "~" can be expanded out to a
  special directory name.  No such facility exists using the file
  URI scheme; a tilde in a file URI is always just a tilde.

The "fix" introduced by this commit makes .full return the path
without file:// prepended. That's conservative. It could also chose
to expand the tilde, which is arguably cleaner. To be introduced by a
later change after this commit has seen more coverage.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-07-22 11:40:58 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!48
No description provided.