Links that point at a section of a page are refused when the fragment comes straight after the domain. https://docs.example.com#installation is rejected with "Not a valid URL.", while https://docs.example.com/#installati…
Links that point at a section of a page are refused when the fragment comes straight after the domain. https://docs.example.com#installation is rejected with "Not a valid URL.", while https://docs.example.com/#installation is accepted. People paste links like the first one from single-page apps all the time, and our forms turn them away.
from marshmallow import validate
validate.URL()("http://example.org#fragment")
validate.URL(relative=True)("#frag")
Each call returns the value it was given.
Each call raises ValidationError: Not a valid URL.
http://example.org/path#frag, http://example.org?x=1#frag.http://example.org# and http://example.org#a b stay invalid.relative=True, #frag on its own stays invalid.Adapted from marshmallow-code/marshmallow (MIT).
Visible test command
pytest testsThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
url-validator-rejects-fragment-after-domain
Changes under src/ are evaluated.