Skip to content

Commit d09ca0c

Browse files
jkyberneeesCopilot
andauthored
refactor: replace JSDOM with Cheerio for HTML parsing (#5)
* refactor: replace JSDOM with Cheerio for HTML parsing in browser and Node.js environments - Updated package.json to include Cheerio as a dependency and modified the test command to include coverage. - Refactored csp-generator.browser.ts to use Cheerio for parsing HTML instead of DOMParser, allowing for better compatibility in Node.js/Bun environments. - Updated csp-generator.ts to utilize Cheerio for parsing and extracting resource references, replacing JSDOM usage. - Removed JSDOM setup from browser tests and adjusted tests to work with the new Cheerio implementation. * Update test/csp-generator.browser.test.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent a7f7b16 commit d09ca0c

File tree

5 files changed

+193
-231
lines changed

5 files changed

+193
-231
lines changed

bun.lock

Lines changed: 21 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build:browser": "bun build ./src/csp-generator.browser.ts --outdir ./dist --target browser --minify --outfile csp-generator.browser.js --format esm",
3131
"build:types": "tsc --emitDeclarationOnly --declaration --project tsconfig.json",
3232
"prepublishOnly": "bun run build",
33-
"test": "bun test",
33+
"test": "bun test --coverage",
3434
"lint": "npx prettier --check **/*.ts",
3535
"format": "prettier --write **/*.ts",
3636
"deploy": "bun run build && bun publish"
@@ -48,15 +48,14 @@
4848
"devDependencies": {
4949
"@types/bun": "latest",
5050
"@types/content-type": "^1.1.8",
51-
"@types/jsdom": "^21.1.7",
5251
"prettier": "^3.5.3"
5352
},
5453
"peerDependencies": {
5554
"typescript": "^5"
5655
},
5756
"dependencies": {
58-
"content-type": "^1.0.5",
59-
"jsdom": "^26.1.0"
57+
"cheerio": "^1.0.0",
58+
"content-type": "^1.0.5"
6059
},
6160
"bugs": {
6261
"url": "https://github.com/BackendStack21/csp-generator/issues"

0 commit comments

Comments
 (0)