Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Unescape numerical HTML entities. #28

Merged
merged 2 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function transformName(name) {
}

// Regex for matching HTML entities.
const entityRegex = new RegExp('&[a-z0-9]+;', 'gi')
const entityRegex = new RegExp('&[a-z0-9#]+;', 'gi')
// Element for setting innerHTML for transforming entities.
let el = null;

Expand Down
4 changes: 2 additions & 2 deletions test/tests/strings_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ describe("#virtualizeString", () => {
});

it("should decode HTML entities, since VNodes just deal with text content", () => {
expect(virtualizeString("<div>&amp; is an ampersand! and &frac12; is 1/2!</div>")).to.deep.equal(
h('div', [ '& is an ampersand! and ½ is 1/2!' ])
expect(virtualizeString("<div>&amp; is an ampersand! and &frac12; is 1/2! and &#xA9; is copyright!</div>")).to.deep.equal(
h('div', [ '& is an ampersand! and ½ is 1/2! and © is copyright!' ])
);
expect(virtualizeString("<a href='http://example.com?test=true&amp;something=false'>Test</a>")).to.deep.equal(
h('a', {
Expand Down