Issue: Incorrect port matching #141

Closed
opened 2025-12-29 14:23:26 +01:00 by adam · 3 comments
Owner

Originally created by @alec-anikin on GitHub (Sep 5, 2018).

Hi!
Regex from PortUtil.UrlDetailsRegex doesn't work for urls like "http://0.0.0.0:5000"
It should be ^(?<proto>\w+)://[^/]+?:(?<port>\d+)/?

Originally created by @alec-anikin on GitHub (Sep 5, 2018). Hi! Regex from PortUtil.UrlDetailsRegex doesn't work for urls like "http://0.0.0.0:5000" It should be `^(?<proto>\w+)://[^/]+?:(?<port>\d+)/?`
adam closed this issue 2025-12-29 14:23:27 +01:00
Author
Owner

@StefH commented on GitHub (Sep 11, 2018):

Hello @alec-anikin, thanks for reporting.

However, maybe updating the regex even further to ^((?<proto>\w+)://)(?<host>[^/]+?):(?<port>\d+)\/?$ is even better?

For https://0.0.0.0:5000 , this matches like:
afbeelding

And for https://localhost:5000 , this matches like:
afbeelding

@StefH commented on GitHub (Sep 11, 2018): Hello @alec-anikin, thanks for reporting. However, maybe updating the regex even further to `^((?<proto>\w+)://)(?<host>[^/]+?):(?<port>\d+)\/?$` is even better? For `https://0.0.0.0:5000` , this matches like: ![afbeelding](https://user-images.githubusercontent.com/249938/45348735-b8da0400-b5af-11e8-9567-409e25e3f235.png) And for `https://localhost:5000` , this matches like: ![afbeelding](https://user-images.githubusercontent.com/249938/45348785-d909c300-b5af-11e8-82ce-87f44c1fe9df.png)
Author
Owner

@StefH commented on GitHub (Sep 17, 2018):

Hi @alec-anikin ; what do you think?

@StefH commented on GitHub (Sep 17, 2018): Hi @alec-anikin ; what do you think?
Author
Owner

@StefH commented on GitHub (Sep 20, 2018):

Will be fixed in PR

@StefH commented on GitHub (Sep 20, 2018): Will be fixed in PR
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#141