Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly format URLs when address is IPv6 #1104

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikkeloscar
Copy link
Member

If an IPv6 address includes port it must be formatted with surrounding []

This adds logic to optionally add surrounding [] if the IP address is IPv6.

Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>
@mikkeloscar mikkeloscar marked this pull request as draft April 8, 2025 14:05
@FxKu FxKu added the bugfix Bug fixes and patches, e.g. fixing of a production issue that is affecting the customer experience. label Apr 8, 2025
@FxKu FxKu marked this pull request as ready for review April 8, 2025 16:05
@@ -718,6 +722,12 @@ def get_placeholders(provider):
return placeholders


def format_url(host, port):
if ":" in host:
return "[" + host + "]" + ":" + port
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this does also work with ipv4?

Copy link
Member Author

@mikkeloscar mikkeloscar Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if a host (without port) has : in it it indicates IPv6 address and we add the [] if not we leave it as is.

(I was testing this change internally to validate that it works, hence the PR was in draft, it probably changed when you commented)

@mikkeloscar mikkeloscar marked this pull request as draft April 8, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug fixes and patches, e.g. fixing of a production issue that is affecting the customer experience.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants