This commit is contained in:
Michael Puckett 2023-08-05 15:00:09 -07:00
parent 139265023a
commit 8dca0641f5
2 changed files with 33 additions and 7 deletions

View File

@ -204,22 +204,25 @@ export const USERNAME_REGEXP = /^[\w\d]{3,12}$/;
* @see {@link W3ID_SECURITY_CONTEXT}
* @see {@link SCHEMA_ORG_CONTEXT}
*/
export const DEFAULT_ACTOR_CONTEXT = {
'@vocab': ACTIVITYSTREAMS_CONTEXT,
sec: W3ID_SECURITY_CONTEXT,
schema: SCHEMA_ORG_CONTEXT,
};
export const DEFAULT_ACTOR_CONTEXT = [
W3ID_SECURITY_CONTEXT,
ACTIVITYSTREAMS_CONTEXT,
{
schema: SCHEMA_ORG_CONTEXT,
},
];
/**
* The default JSON-LD context for ActivityPub Actors, with instances of URL in
* place of strings.
*/
*
export const DEFAULT_ACTOR_CONTEXT_AS_URLS = Object.fromEntries(
Object.entries(DEFAULT_ACTOR_CONTEXT).map(([key, value]) => [
key,
new URL(value),
]),
);
*/
/**
* Express-style route parameters.

View File

@ -3,7 +3,7 @@ import 'jasmine';
import { compactJsonObject } from '../src/compactJsonObject';
describe('compactJsonObject', () => {
it('should compact a JSON object', async () => {
it('should maintain JSON object', async () => {
const compacted = await compactJsonObject({
'@context': 'https://www.w3.org/ns/activitystreams',
id: 'https://example.com',
@ -18,4 +18,27 @@ describe('compactJsonObject', () => {
name: 'Example',
});
});
it('should compact plain JSON object', async () => {
const compacted = await compactJsonObject({
id: 'https://example.com',
type: 'Person',
name: 'Example',
image: {
type: 'Image',
url: 'https://example.com/image.png',
},
});
expect(compacted).toEqual({
'@context': 'https://www.w3.org/ns/activitystreams',
id: 'https://example.com',
type: 'Person',
name: 'Example',
image: {
type: 'Image',
url: 'https://example.com/image.png',
},
});
});
});