mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Add IANA type to child metadata in FileDataAccessor
This commit is contained in:
@@ -13,8 +13,8 @@ import type { Guarded } from '../../util/GuardedStream';
|
||||
import { joinFilePath, isContainerIdentifier } from '../../util/PathUtil';
|
||||
import { parseQuads, serializeQuads } from '../../util/QuadUtil';
|
||||
import { addResourceMetadata, updateModifiedDate } from '../../util/ResourceUtil';
|
||||
import { toLiteral } from '../../util/TermUtil';
|
||||
import { CONTENT_TYPE, DC, LDP, POSIX, RDF, SOLID_META, XSD } from '../../util/Vocabularies';
|
||||
import { toLiteral, toNamedTerm } from '../../util/TermUtil';
|
||||
import { CONTENT_TYPE, DC, IANA, LDP, POSIX, RDF, SOLID_META, XSD } from '../../util/Vocabularies';
|
||||
import type { FileIdentifierMapper, ResourceLink } from '../mapping/FileIdentifierMapper';
|
||||
import type { DataAccessor } from './DataAccessor';
|
||||
|
||||
@@ -297,10 +297,16 @@ export class FileDataAccessor implements DataAccessor {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generate metadata of this specific child
|
||||
// Generate metadata of this specific child as described in
|
||||
// https://solidproject.org/TR/2021/protocol-20211217#contained-resource-metadata
|
||||
const metadata = new RepresentationMetadata(childLink.identifier);
|
||||
addResourceMetadata(metadata, childStats.isDirectory());
|
||||
this.addPosixMetadata(metadata, childStats);
|
||||
// Containers will not have a content-type
|
||||
if (childLink.contentType) {
|
||||
metadata.add(RDF.terms.type, toNamedTerm(`${IANA.namespace}${childLink.contentType}#Resource`));
|
||||
}
|
||||
|
||||
yield metadata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ export const HTTP = createUriAndTermNamespace('http://www.w3.org/2011/http#',
|
||||
'statusCodeNumber',
|
||||
);
|
||||
|
||||
export const IANA = createUriAndTermNamespace('http://www.w3.org/ns/iana/media-types/');
|
||||
|
||||
export const LDP = createUriAndTermNamespace('http://www.w3.org/ns/ldp#',
|
||||
'contains',
|
||||
|
||||
|
||||
@@ -176,6 +176,7 @@ describe('A FileDataAccessor', (): void => {
|
||||
for (const child of children.filter(({ identifier }): boolean => !identifier.value.endsWith('/'))) {
|
||||
const types = child.getAll(RDF.type).map((term): string => term.value);
|
||||
expect(types).toContain(LDP.Resource);
|
||||
expect(types).toContain('http://www.w3.org/ns/iana/media-types/application/octet-stream#Resource');
|
||||
expect(types).not.toContain(LDP.Container);
|
||||
expect(types).not.toContain(LDP.BasicContainer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user