Skip to content

Commit

Permalink
feat: use entities package instead of he. fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed May 13, 2024
1 parent ae3ad37 commit 85b97a5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"watch": "npm run build:tsup -- --watch"
},
"dependencies": {
"css-what": "^6.1.0"
"css-what": "^6.1.0",
"entities": "^4.5.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.17.0",
Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions src/encoding.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { escapeHTML } from './encoding'
import { escapeHTML, unescapeHTML } from './encoding'

describe('encoding', () => {
it('should encoding', () => {
it('should encode', () => {
expect(escapeHTML('</')).toEqual('&lt;/')
expect(escapeHTML('<and> &')).toEqual('&lt;and&gt; &amp;')
})

it("should decode", () => {
expect(unescapeHTML('&amp; &#x3A; &copy;')).toEqual('& : ©')
})
})
3 changes: 2 additions & 1 deletion src/encoding.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { decode } from './encoding-he'
// import { decode } from './encoding-he'
import { decodeHTML as decode} from 'entities'

export function escapeHTML(text: string) {
return text
Expand Down

0 comments on commit 85b97a5

Please sign in to comment.