feedsmith
Version:
Fast, all‑in‑one feed parser and generator for RSS, Atom, RDF, and JSON Feed, with support for Podcast, iTunes, Dublin Core, and OPML files.
15 lines (14 loc) • 647 B
JavaScript
import { namespaceUris } from "../../../common/config.js";
import { isNonEmptyString } from "../../../common/utils.js";
//#region src/feeds/atom/detect/index.ts
const feedElementRegex = /(?:^|[\s>])<(?:\w+:)?feed[\s>]/im;
const atomElementsRegex = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i;
const detect = (value) => {
if (!isNonEmptyString(value)) return false;
if (!feedElementRegex.test(value)) return false;
const hasAtomNamespace = namespaceUris.atom.some((uri) => value.includes(uri));
const hasAtomElements = atomElementsRegex.test(value);
return hasAtomNamespace || hasAtomElements;
};
//#endregion
export { detect };