Skip to content

Commit 7f47745

Browse files
committed
Work around improperly served RDF/XML from CIDOC CRM (#455)
1 parent b948751 commit 7f47745

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

frontend/src/common-rdf/sync.ts

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const priorityOverrides = {
2424
'application/n-quads': 0.6,
2525
};
2626

27+
// CIDOC serves its rdf/xml with a text/html content type. ARGH!
28+
const rdfPattern = /<\?xml[^]+<rdf:rdf[^]+<\/rdf:rdf/i;
29+
2730
const defaultSyncOptions = (function() {
2831
let optionsPromise: any;
2932

@@ -86,6 +89,11 @@ export function transform(jqXHR: JQuery.jqXHR): Promise<[
8689
} else {
8790
plaintext = jqXHR.responseText;
8891
}
92+
if (contentType === 'text/html' && rdfPattern.test(plaintext)) {
93+
// Workaround for improper content negotiation in CIDOC and possibly
94+
// other vocabularies.
95+
contentType = 'application/rdf+xml';
96+
}
8997
const input = streamify(plaintext);
9098
const serializer = new Serializer();
9199
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)