Skip to content

Commit 35a2e84

Browse files
authored
Update util.js
1 parent 2555500 commit 35a2e84

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine
44
const ENCODED_ENTITIES = /[&<>"]/;
55

66
export function encodeEntities(str) {
7-
if (ENCODED_ENTITIES.test(s) === false) return s;
7+
// Skip all work for strings with no entities needing encoding:
8+
if (ENCODED_ENTITIES.test(str) === false) return str;
9+
810
let start = 0,
911
i = 0,
1012
out = '',
1113
ch = '';
1214
for (; i<str.length; i++) {
13-
switch(str.charCodeAt(i)) {
15+
switch (str.charCodeAt(i)) {
1416
case 60: ch = '&lt;'; break;
1517
case 62: ch = '&gt;'; break;
1618
case 34: ch = '&quot;'; break;

0 commit comments

Comments
 (0)