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 +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1075,8 +1075,12 @@ function extractEntry(entryElement) {
|
|
|
1075
1075
|
function removeComments(xml) {
|
|
1076
1076
|
return xml.replace(/<!--[\s\S]*?-->/g, "");
|
|
1077
1077
|
}
|
|
1078
|
+
function removeDoctype(xml) {
|
|
1079
|
+
return xml.replace(/<!DOCTYPE[^>]*>/gi, "");
|
|
1080
|
+
}
|
|
1078
1081
|
function parseAtomXML(xml) {
|
|
1079
|
-
const
|
|
1082
|
+
const withoutDoctype = removeDoctype(xml);
|
|
1083
|
+
const withoutComments = removeComments(withoutDoctype);
|
|
1080
1084
|
const { text: cleanedXML, cdataMap } = extractCDATA(withoutComments);
|
|
1081
1085
|
const root = parseElement(cleanedXML, 0, null, cdataMap).element;
|
|
1082
1086
|
return root;
|
|
@@ -1884,13 +1888,17 @@ function parseRSSDate(dateString) {
|
|
|
1884
1888
|
// src/feed/rss/xml-parser.ts
|
|
1885
1889
|
function parseRSSXML(xml) {
|
|
1886
1890
|
const cleaned = cleanXMLDeclaration(xml);
|
|
1887
|
-
const
|
|
1891
|
+
const withoutDoctype = removeDoctype2(cleaned);
|
|
1892
|
+
const withoutComments = removeComments2(withoutDoctype);
|
|
1888
1893
|
const root = parseElement2(withoutComments, 0).element;
|
|
1889
1894
|
return root;
|
|
1890
1895
|
}
|
|
1891
1896
|
function cleanXMLDeclaration(xml) {
|
|
1892
1897
|
return xml.replace(/<\?xml[^?]*\?>/g, "").trim();
|
|
1893
1898
|
}
|
|
1899
|
+
function removeDoctype2(xml) {
|
|
1900
|
+
return xml.replace(/<!DOCTYPE[^>]*>/gi, "");
|
|
1901
|
+
}
|
|
1894
1902
|
function removeComments2(xml) {
|
|
1895
1903
|
return xml.replace(/<!--[\s\S]*?-->/g, "");
|
|
1896
1904
|
}
|