mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Streamline RepresentationMetadata interface
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { RepresentationPreference } from '../../ldp/representation/RepresentationPreference';
|
||||
import { RepresentationPreferences } from '../../ldp/representation/RepresentationPreferences';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
import { CONTENT_TYPE } from '../../util/MetadataTypes';
|
||||
import { matchingMediaType } from '../../util/Util';
|
||||
import { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
|
||||
@@ -35,11 +34,11 @@ RepresentationPreference[] => {
|
||||
*/
|
||||
export const checkRequest = (request: RepresentationConverterArgs, supportedIn: string[], supportedOut: string[]):
|
||||
void => {
|
||||
const inType = request.representation.metadata.get(CONTENT_TYPE);
|
||||
const inType = request.representation.metadata.contentType;
|
||||
if (!inType) {
|
||||
throw new UnsupportedHttpError('Input type required for conversion.');
|
||||
}
|
||||
if (!supportedIn.some((type): boolean => matchingMediaType(inType.value, type))) {
|
||||
if (!supportedIn.some((type): boolean => matchingMediaType(inType, type))) {
|
||||
throw new UnsupportedHttpError(`Can only convert from ${supportedIn} to ${supportedOut}.`);
|
||||
}
|
||||
if (matchingTypes(request.preferences, supportedOut).length <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user