Skip to content

Correctly format URLs when address is IPv6#1104

Closed
mikkeloscar wants to merge 1 commit intozalando:masterfrom
mikkeloscar:format-ipv6-addresses
Closed

Correctly format URLs when address is IPv6#1104
mikkeloscar wants to merge 1 commit intozalando:masterfrom
mikkeloscar:format-ipv6-addresses

Conversation

@mikkeloscar
Copy link
Copy Markdown
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 <mikkel.larsen@zalando.de>
@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

def format_url(host, port):
if ":" in host:
return "[" + host + "]" + ":" + port
Copy link
Copy Markdown
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
Copy Markdown
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
@hughcapet hughcapet changed the base branch from master to trigger April 16, 2025 12:44
@hughcapet hughcapet changed the base branch from trigger to master April 16, 2025 12:44
@mikkeloscar
Copy link
Copy Markdown
Member Author

Closing as this change doesn't seem to be relevant/needed.

@mikkeloscar mikkeloscar closed this May 5, 2025
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