Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "yaml-ld"
version = "1.1.15"
version = "1.1.16"
description = "YAML-LD for Python"
authors = ["Anatoly Scherbakov <altaisoft@gmail.com>"]
license = "MIT"
Expand Down
19 changes: 13 additions & 6 deletions yaml_ld/document_loaders/content_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
# - I've copied it over from pyld;
# - It is hard-coded, I think I should handle it dynamically depending on
# whatever parsers are available.
APPLICATION_LD_JSON = 'application/ld+json'

DEFAULT_ACCEPT_HEADER = ', '.join([
'application/ld+json',
APPLICATION_LD_JSON,
'application/rdf+xml;q=0.8',
'application/json;q=0.5',
'text/html;q=0.8',
Expand Down Expand Up @@ -48,7 +50,12 @@ def construct_accept_header(url: URI) -> str:
if url.startswith('https://w3id.org/fair/fip/terms/'):
# Content negotiation will not work correctly because w3id does not
# support content type weights. It will return the text/html version.
return 'application/ld+json'
return APPLICATION_LD_JSON

if url.startswith('http://www.w3.org/ns/prov'):
# Content negotiation will not work correctly because w3.org does not
# handle weights for this namespace and returns the HTML variant.
return 'text/turtle'

return DEFAULT_ACCEPT_HEADER

Expand All @@ -61,9 +68,9 @@ def by_extension(extension: str) -> str | None:
"""
return {
'.json': 'application/json',
'.jsonld': 'application/ld+json',
'.jldt': 'application/ld+json',
'.jldte': 'application/ld+json',
'.jsonld': APPLICATION_LD_JSON,
'.jldt': APPLICATION_LD_JSON,
'.jldte': APPLICATION_LD_JSON,
'.yaml': 'application/yaml',
'.yamlld': 'application/ld+yaml',
'.html': 'text/html',
Expand All @@ -89,7 +96,7 @@ def parser_by_content_type_map():

return {
'application/json': YAMLDocumentParser,
'application/ld+json': YAMLDocumentParser,
APPLICATION_LD_JSON: YAMLDocumentParser,
'application/yaml': YAMLDocumentParser,
'application/x-yaml': YAMLDocumentParser,
'application/ld+yaml': YAMLDocumentParser,
Expand Down
Loading