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

feat: allow custom URL scheme validation #409

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

Conversation

e3krisztian
Copy link

Enhances validators.url to allow

  • restricting the allowed schemes (e.g. to accept only https, and nothing else)
  • relaxing the allowed schemes to also accept less known schemes (e.g. ws, wss, ldap, ...)

This backward compatible change let's library users resolve the problematic cases requested/discussed in

Enhances `validators.url` to allow
- restricting the allowed schemes (e.g. to accept only https,
                                   and nothing else)
- relaxing the allowed schemes to also accept less known schemes
  (e.g. ws, wss, ldap, ...)
@yozachar yozachar self-requested a review November 30, 2024 06:09
@yozachar
Copy link
Collaborator

yozachar commented Nov 30, 2024

The only issue I see is that I could pass something as dumb as:

url('httpx://crazy.example', validate_scheme=lambda x: True)

This then resolves to: #396 (comment)

@yozachar yozachar added waiting Issue/PR: Wating for reply maintenance PR: Alters existing source code labels Nov 30, 2024
@e3krisztian
Copy link
Author

The only issue I see is that I could pass something as dumb as:

url('httpx://crazy.example', validate_scheme=lambda x: True)

This then resolves to: #396 (comment)

I do not understand what is the issue mentioned above, and what part of the linked comment is relevant.

Users want to have control over the accepted url schemes, because their problems define the schemes to work with which are not universal (e.g. only svn+ssh://... URLs makes sense in their problem domain).

Now some potential users can not use the functionality in the library, because the scheme check is too strict for them.
The example always succeeding the scheme check is something, that these people may love to have. Having the remaining checks might be valuable enough for them to implement custom scheme validation if needed.

In the end, doing something dumb is the users responsibility - maybe what they end up with is a novel, but valid use :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance PR: Alters existing source code waiting Issue/PR: Wating for reply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants