Open agates opened 1 month ago
>>> rfc3987.parse("https://example.com/feed.xml", "IRI")
{'scheme': 'https', 'authority': 'example.com', 'path': '/feed.xml', 'query': None, 'fragment': None}
>>> rfc3987.parse("ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html", "IRI")
{'scheme': 'ipfs', 'authority': 'bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq', 'path': '/wiki/Vincent_van_Gogh.html', 'query': None, 'fragment': None}
>>> rfc3987.parse("://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html", "IRI")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/agates/.cache/pypoetry/virtualenvs/podping-hivewriter-GQ5UIonf-py3.10/lib/python3.10/site-packages/rfc3987.py", line 462, in parse
raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: '://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html' is not a valid 'IRI'.
>>> rfc3987.parse("ipfs://", "IRI")
{'scheme': 'ipfs', 'authority': '', 'path': '', 'query': None, 'fragment': None}
>>> rfc3987.parse("ipfs:test", "IRI")
{'scheme': 'ipfs', 'authority': None, 'path': 'test', 'query': None, 'fragment': None}
>>> rfc3987.parse("ipfs:test/example", "IRI")
{'scheme': 'ipfs', 'authority': None, 'path': 'test/example', 'query': None, 'fragment': None}
>>> rfc3987.parse("urn:btih:testing", "IRI")
{'scheme': 'urn', 'authority': None, 'path': 'btih:testing', 'query': None, 'fragment': None}
Need to check for non-empty scheme OR non-empty authority. Don't need both.
Existing code: https://github.com/Podcastindex-org/podping-hivewriter/blob/7162b580e7d9822ba117947dc6e154f82dffd839/src/podping_hivewriter/podping_hivewriter.py#L549-L550