Skip to content

Commit 68cbcff

Browse files
committed
Factor out buildSchemes helper
1 parent 6da0199 commit 68cbcff

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/collection-api/routes/feed.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,18 @@ function buildFeedId(tagAuthority, collection, ...suffix) {
5959
return [ `tag:${tagAuthority}:feed`, collection.metadata?.id, ...suffix ].join(':');
6060
}
6161

62+
function buildSchemes(tagAuthority) {
63+
return {
64+
service: `tag:${tagAuthority}:scheme:service`,
65+
termsType: `tag:${tagAuthority}:scheme:terms-type`,
66+
recordType: `tag:${tagAuthority}:scheme:record-type`,
67+
};
68+
}
69+
6270
function buildEntry(tagAuthority, storageType, baseUrl, collection, version) {
6371
const apiLink = buildVersionLink(baseUrl, version);
6472
const githubCommitLink = collection.metadata?.versions && `${collection.metadata.versions}/commit/${version.id}`;
73+
const schemes = buildSchemes(tagAuthority);
6574

6675
const links = [{ _attributes: { rel: 'alternate', type: 'text/html', href: githubCommitLink || apiLink } }];
6776

@@ -75,9 +84,9 @@ function buildEntry(tagAuthority, storageType, baseUrl, collection, version) {
7584
title: { _text: buildEntryTitle(version) },
7685
updated: { _text: version.fetchDate.toISOString() },
7786
category: [
78-
{ _attributes: { term: version.serviceId, scheme: `tag:${tagAuthority}:scheme:service` } },
79-
{ _attributes: { term: version.termsType, scheme: `tag:${tagAuthority}:scheme:terms-type` } },
80-
{ _attributes: { term: classifyRecordType(version), scheme: `tag:${tagAuthority}:scheme:record-type` } },
87+
{ _attributes: { term: version.serviceId, scheme: schemes.service } },
88+
{ _attributes: { term: version.termsType, scheme: schemes.termsType } },
89+
{ _attributes: { term: classifyRecordType(version), scheme: schemes.recordType } },
8190
],
8291
};
8392
}

0 commit comments

Comments
 (0)