Skip to content

Commit 66248c6

Browse files
authored
Prevent errors when processing additional rdf metadata (#2496)
1 parent d8c2a7b commit 66248c6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

web-marketplace/src/lib/rdf/rdf.compact.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ContextDefinition, JsonLdDocument, NodeObject } from 'jsonld';
33

44
import { COMPACTED_CONTEXT } from './rdf.constants';
55

6+
// TODO: Support documents with @graph
67
export const jsonLdCompact = async (
78
data: JsonLdDocument,
89
context?: object,

web-marketplace/src/lib/rdf/rdf.unknown-fields.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88

99
function getUnknowFields(data: object, knownFields: string[]) {
1010
return Object.entries(data).filter(
11-
([key]) => !['@context', '@type', '@id', ...knownFields].includes(key),
11+
([key]) => !['@context', '@graph', '@type', '@id', ...knownFields].includes(key),
1212
);
1313
}
1414

@@ -127,7 +127,8 @@ export function getBatchUnknownFields<
127127
}
128128

129129
export function getFieldLabel(fieldName: string) {
130-
return fieldName.split(':')[1].replace(/([A-Z])/g, ' $1');
130+
// Remove the field prefix and add space before capital letters.
131+
return fieldName.replace(/[^:]*\:/, '').replace(/([A-Z])/g, ' $1');
131132
}
132133

133134
export function getFieldType(fieldName: string, context?: ContextDefinition) {

0 commit comments

Comments
 (0)