wycherley22
wycherley22

Reputation: 69

How to change <rights> tag to <copyright> in Atom feed?

I am using the feed module to generate an Atom feed in CAP format. Here is the code I am using to generate the feed:

const feed = new Feed({
    title: 'Event Notifications',
    generator: 'Custom CAP XML Generator',
    description: 'Notifications for events',
    id: config.url + '/notifications.atom',
    link: config.url + '/notifications.atom',
    updated: new Date(),
    author: {
      name: 'Notification Agency',
      email: '[email protected]',
      link: 'https://www.notification-agency.example.com'
    },
    copyright: 'https://www.example.com/open-license'
});

I have been asked to change the <rights> tag to <copyright> in the generated feed. However, the module automatically generates a <rights> tag, and all the documentation I found indicates that it should be <rights>. I am not sure enough about the CAP format or Atom feeds to confirm if this is correct or if I should push back on this request.

If it is indeed correct that the <rights> tag should be <copyright>, I came up with a workaround to "shoehorn" the <copyright> tag into the feed as follows:

const atomFeed = feed.atom1();

const copyrightText = '\n<copyright>Copyright (c) 2024, Notification Agency. Licensed under Creative Commons BY 4.0</copyright>';

const subtitleTag = '</subtitle>';
const subtitlePosition = atomFeed.indexOf(subtitleTag) + subtitleTag.length;
const feedWithCopyright = `${atomFeed.slice(0, subtitlePosition)}${copyrightText}${atomFeed.slice(subtitlePosition)}`;

My questions are:

Upvotes: 0

Views: 41

Answers (1)

wycherley22
wycherley22

Reputation: 69

After more research and pushing back on the ask I've had it confirmed copyright is used in RSS, rights for ATOM. So I can keep it as Atom which makes a lot more sense

Upvotes: 0

Related Questions