aio-libs / aio-libs/yarl

Handling of relative path URL

未關閉
#648 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
1.5k
分支
215
平均合併
1 天 2 分鐘
30 天內合併 PR
13

描述

### Describe the bug

According to rfc 8089 paths for file URIs are absolute. ``yarl.URL`` does not complain about them but displays a wrong repr.

### To Reproduce

1. yarl 1.7.2
2. Instantiate file URL with "relative" path (see below)

### Expected behavior

``yarl.URL('file:foo/bar')`` should raise exception or produce instance with correct repr: ``assert repr(URL('file:foo/bar')) == 'file:foo/bar'``

### Logs/tracebacks

```python-traceback
In [1]: from yarl import URL

In [2]: URL('file:foo/bar') == URL('file:///foo/bar')
Out[2]: False

In [3]: URL('file:///foo/bar')
Out[3]: URL('file:///foo/bar')

In [4]: URL('file:foo/bar')
Out[4]: URL('file:///foo/bar')

In [5]: URL('file:foo/bar').path
Out[5]: 'foo/bar'

In [6]: URL('file:///foo/bar').path
Out[6]: '/foo/bar'
```
```

### Python Version

```console
$ python --version
3.8.12
```

### multidict Version

```console
$ python -m pip show multidict
5.1.0
```

### yarl Version

```console
$ python -m pip show yarl
1.7.2
```

### OS

NixOS

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow the aio-libs Code of Conduct

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。