Initial Checks
Description
I rely on the fact that my URLs don't have any trailing slashes, so I had a validator that stripped the trailing slash in pydantic v1.
In pydantic v2, the AnyHttpUrl type always appends a slash to the URL even if none is provided.
Example Code
from pydantic import AnyHttpUrl
assert str(AnyHttpUrl("http://example.org")) == "http://example.org" # Fails
assert str(AnyHttpUrl("http://example.org")) == "http://example.org/" # Succeed
Python, Pydantic & OS Version
pydantic version: 2.1.1
pydantic-core version: 2.4.0
pydantic-core build: profile=release pgo=true mimalloc=true
install path: /home/jo/code/github.com/libretime/libretime/shared/.venv/lib/python3.11/site-packages/pydantic
python version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
platform: Linux-6.1.0-10-amd64-x86_64-with-glibc2.36
optional deps. installed: ['typing-extensions']
Selected Assignee: @adriangb
Initial Checks
Description
I rely on the fact that my URLs don't have any trailing slashes, so I had a validator that stripped the trailing slash in pydantic v1.
In pydantic v2, the
AnyHttpUrltype always appends a slash to the URL even if none is provided.Example Code
Python, Pydantic & OS Version
Selected Assignee: @adriangb