Title
UNC paths are broken when parsing file:// URIs (authority ignored, round-trip fails)
Description
First of all, thank you for maintaining this great library — it’s very useful and appreciated.
I’ve encountered an issue when handling UNC paths via file:// URIs, where the authority component is ignored and the path is incorrectly interpreted as a local path.
Reproduction
from upath import UPath
p = UPath(r'\\server\share\file')
uri = p.as_uri()
print(uri)
# 'file://server/share/file'
p2 = UPath(uri)
print(p2)
# 'file://C://server/share/file'
Expected behavior
file://server/share/file represents a UNC path and should round-trip correctly:
UPath("file://server/share/file")
# -> WindowsUPath('//server/share/file')
Actual behavior
The authority (server) is dropped and interpreted as part of a local path:
FilePath('C://server/share/file', protocol='file')
This is not equivalent to the original UNC path.
Comparison with pathlib (Python 3.14)
from pathlib import Path
p = Path(r'\\server\share\file')
uri = p.as_uri()
Path.from_uri(uri)
# -> WindowsPath('//server/share/file') # correct
pathlib correctly preserves UNC semantics, while UPath does not.
Impact
- Round-trip is broken:
p != UPath(p.as_uri())
- UNC paths are corrupted
- Produces invalid Windows paths
Suggested fix
When parsing file:// URIs:
Environment
- upath: 0.3.10
- Python: 3.14
- OS: Windows
Notes
I searched existing issues using:
but could not find a matching report.
Title
UNC paths are broken when parsing
file://URIs (authority ignored, round-trip fails)Description
First of all, thank you for maintaining this great library — it’s very useful and appreciated.
I’ve encountered an issue when handling UNC paths via
file://URIs, where the authority component is ignored and the path is incorrectly interpreted as a local path.Reproduction
Expected behavior
file://server/share/filerepresents a UNC path and should round-trip correctly:Actual behavior
The authority (
server) is dropped and interpreted as part of a local path:This is not equivalent to the original UNC path.
Comparison with pathlib (Python 3.14)
pathlibcorrectly preserves UNC semantics, whileUPathdoes not.Impact
p != UPath(p.as_uri())Suggested fix
When parsing
file://URIs:If
netloc(authority) is non-empty → treat as UNC:Otherwise → handle as a local path (
file:///C:/...)Environment
Notes
I searched existing issues using:
but could not find a matching report.