mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Components.js supports Record now.
This commit is contained in:
parent
6b4088723d
commit
961662b692
@ -10,9 +10,7 @@ import { MetadataWriter } from './MetadataWriter';
|
||||
export class LinkRelMetadataWriter extends MetadataWriter {
|
||||
private readonly linkRelMap: Record<string, string>;
|
||||
|
||||
// Not supported by Components.js yet
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
public constructor(linkRelMap: { [predicate: string]: string }) {
|
||||
public constructor(linkRelMap: Record<string, string>) {
|
||||
super();
|
||||
this.linkRelMap = linkRelMap;
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ import { MetadataWriter } from './MetadataWriter';
|
||||
export class MappedMetadataWriter extends MetadataWriter {
|
||||
private readonly headerMap: Record<string, string>;
|
||||
|
||||
// Not supported by Components.js yet
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
public constructor(headerMap: { [predicate: string]: string }) {
|
||||
public constructor(headerMap: Record<string, string>) {
|
||||
super();
|
||||
this.headerMap = headerMap;
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ import type { HttpResponse } from '../HttpResponse';
|
||||
export class HeaderHandler extends HttpHandler {
|
||||
private readonly headers: Record<string, string>;
|
||||
|
||||
// Not supported by Components.js yet
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
public constructor(headers: { [header: string]: string } = {}) {
|
||||
public constructor(headers: Record<string, string>) {
|
||||
super();
|
||||
this.headers = { ...headers };
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ export class RegexRouterRule extends RouterRule {
|
||||
/**
|
||||
* The keys of the `storeMap` will be converted into actual RegExp objects that will be used for testing.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
public constructor(base: string, storeMap: { [ regex: string ]: ResourceStore }) {
|
||||
public constructor(base: string, storeMap: Record<string, ResourceStore>) {
|
||||
super();
|
||||
this.base = trimTrailingSlashes(base);
|
||||
this.regexes = new Map(Object.keys(storeMap).map((regex): [ RegExp, ResourceStore ] =>
|
||||
|
@ -3,16 +3,6 @@ import { HeaderHandler } from '../../../../src/server/middleware/HeaderHandler';
|
||||
import { guardStream } from '../../../../src/util/GuardedStream';
|
||||
|
||||
describe('a HeaderHandler', (): void => {
|
||||
it('adds no headers when none are configured.', async(): Promise<void> => {
|
||||
const handler = new HeaderHandler();
|
||||
|
||||
const request = guardStream(createRequest());
|
||||
const response = createResponse();
|
||||
await handler.handleSafe({ request, response });
|
||||
|
||||
expect(response.getHeaders()).toEqual({});
|
||||
});
|
||||
|
||||
it('adds all configured headers.', async(): Promise<void> => {
|
||||
const headers = { custom: 'Custom', other: 'Other' };
|
||||
const handler = new HeaderHandler(headers);
|
||||
|
Loading…
x
Reference in New Issue
Block a user