Skip to content

Request to add URL.join() to correctly join/construct new URLs #9794

Open
pydantic/pydantic-core
#1378
@Ravencentric

Description

@Ravencentric

Initial Checks

  • I have searched Google & GitHub for similar requests and couldn't find anything
  • I have read and followed the docs and still think this feature is missing

Description

A method to correctly join URLs:

>>> a = Url("https://example.com/")

>>> a.join("user/John")
Url('https://example.com/user/John')

>>> a.join("/user/John")
Url('https://example.com/user/John')

>>> a / "user" / "John" # Similar to pathlib's __truediv__? Would be quite neat but may be too confusing?
Url('https://example.com/user/John')

This would be really helpful when dealing with URLs, so you don't have to keep a track of / on your own.

Affected Components

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions