Skip to content

Commit

Permalink
feat: Remove xmldom
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Nov 22, 2024
1 parent 936da5f commit 32436e2
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@tpluscode/rdf-string": "^1.3.3",
"@tpluscode/sparql-builder": "^2.0.3",
"@turf/centroid": "^6.5.0",
"@types/jsdom": "^21.1.7",
"cors": "^2.8.5",
"d3": "^7.9.0",
"fp-ts": "^2.10.4",
Expand All @@ -61,6 +62,7 @@
"har-to-k6": "^0.13.1",
"io-ts": "^2.2.16",
"io-ts-types": "^0.5.16",
"jsdom": "^25.0.1",
"lodash": "^4.17.21",
"make-plural": "^7.0.0",
"micromark": "^2.11.2",
Expand All @@ -83,7 +85,6 @@
"undici": "^5.25.2",
"urql": "^2.0.2",
"xml-c14n": "^0.0.6",
"xmldom": "^0.6.0",
"zod": "^3.17.3"
},
"devDependencies": {
Expand Down Expand Up @@ -120,7 +121,6 @@
"@types/theme-ui": "^0.3.7",
"@types/topojson-client": "^3.1.0",
"@types/xml-c14n": "^0.0.1",
"@types/xmldom": "^0.1.31",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"argparse": "^2.0.1",
Expand Down
8 changes: 5 additions & 3 deletions src/domain/gever/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSDOM } from "jsdom";
import c14nFactory from "xml-c14n";
import { DOMParser, XMLSerializer } from "xmldom";

export const ns = {
a: "http://www.w3.org/2005/08/addressing",
Expand Down Expand Up @@ -63,11 +63,13 @@ export const canonicalizeXML = async (tree: Element): Promise<string> => {
const c14n = c14nFactory();

export const serializeXMLToString = (tree: Element) => {
return new XMLSerializer().serializeToString(tree);
const dom = new JSDOM();
return new dom.window.XMLSerializer().serializeToString(tree);
};

export const parseXMLString = (xmlStr: string) => {
return new DOMParser().parseFromString(xmlStr);
const dom = new JSDOM();
return new dom.window.DOMParser().parseFromString(xmlStr, "text/xml");
};

export const stripWhitespace = (xmlStr: string) => {
Expand Down
Loading

0 comments on commit 32436e2

Please sign in to comment.