Skip to content

URL validator fails with one digit port #84

@kdeltared

Description

@kdeltared

URL validator fails when validating urls with one digit port

>>> validators.url("http://google.com/test")
True
>>> validators.url("http://google.com:80/test")
True
>>> validators.url("http://google.com:10/test")
True
>>> validators.url("http://google.com:9/test")
ValidationFailure(func=url, args={'public': False, 'value': 'http://google.com:9/test'})
>>> validators.url("http://google.com:8/test")
ValidationFailure(func=url, args={'public': False, 'value': 'http://google.com:8/test'})
>>> validators.url("http://google.com:7/test")
ValidationFailure(func=url, args={'public': False, 'value': 'http://google.com:7/test'})
>>> validators.url("http://google.com:2/test")
ValidationFailure(func=url, args={'public': False, 'value': 'http://google.com:2/test'})
>>> validators.url("http://google.com:1/test")
ValidationFailure(func=url, args={'public': False, 'value': 'http://google.com:1/test'})

I think the problem is in this line, forcing the port number having 2 to 5 digits
https://github.com/kvesteri/validators/blob/8cf1e8fb5ed3af3d428b0230c50d63d55dd0939a/validators/url.py#L45

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue: Works not as designedoutdatedIssue/PR: Open for more than 3 months

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions