magpie-html 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1081,8 +1081,12 @@ function extractEntry(entryElement) {
1081
1081
  function removeComments(xml) {
1082
1082
  return xml.replace(/<!--[\s\S]*?-->/g, "");
1083
1083
  }
1084
+ function removeDoctype(xml) {
1085
+ return xml.replace(/<!DOCTYPE[^>]*>/gi, "");
1086
+ }
1084
1087
  function parseAtomXML(xml) {
1085
- const withoutComments = removeComments(xml);
1088
+ const withoutDoctype = removeDoctype(xml);
1089
+ const withoutComments = removeComments(withoutDoctype);
1086
1090
  const { text: cleanedXML, cdataMap } = extractCDATA(withoutComments);
1087
1091
  const root = parseElement(cleanedXML, 0, null, cdataMap).element;
1088
1092
  return root;
@@ -1890,13 +1894,17 @@ function parseRSSDate(dateString) {
1890
1894
  // src/feed/rss/xml-parser.ts
1891
1895
  function parseRSSXML(xml) {
1892
1896
  const cleaned = cleanXMLDeclaration(xml);
1893
- const withoutComments = removeComments2(cleaned);
1897
+ const withoutDoctype = removeDoctype2(cleaned);
1898
+ const withoutComments = removeComments2(withoutDoctype);
1894
1899
  const root = parseElement2(withoutComments, 0).element;
1895
1900
  return root;
1896
1901
  }
1897
1902
  function cleanXMLDeclaration(xml) {
1898
1903
  return xml.replace(/<\?xml[^?]*\?>/g, "").trim();
1899
1904
  }
1905
+ function removeDoctype2(xml) {
1906
+ return xml.replace(/<!DOCTYPE[^>]*>/gi, "");
1907
+ }
1900
1908
  function removeComments2(xml) {
1901
1909
  return xml.replace(/<!--[\s\S]*?-->/g, "");
1902
1910
  }