Allow adding a default source with a base URI of None #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Minimally fixes #75. This can be used to match complete URIs, particularly URN-ish URIs using schemes that do not readily break down into a base and a relative reference.
The details of the change (using a string prefix after verifying the base URI when it is not
None
) is invisible to the public API, and the fundamental semantics are preserved.This is sufficient for the use case that was blocking me: how to load a URI like
tag:modern-json-schema.com,2023-03:something
, which cannot be split. Its only components are the schemetag
and the pathmodern-json-schema.con,2023-03:something
, and that path cannot be used as the start of a relative reference because it contains a:
.Potential workarounds
An alternative would be to register a source for each expected URI using the whole URI as a base URI, but that wouldn't work for URIs not known in advance.
Discarded approaches
I attempted the more flexible
uri_prefix
idea proposed in #75, but it became complicated and required awkward contortions to maintain backwards compatibility in the public API. I decided that the extra flexibility was not worthwhile as a source registered in this way can do whatever re-mapping it wants with therelative_path
, such as converting:
characters to something else so that the URI can be used on Mac OS X filesystems.