Skip to content

Commit a49326b

Browse files
committed
remove unnecessary condition
1 parent b49f4fb commit a49326b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

string.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,24 @@ export const repeat = (source, n) => array.unfold(n, () => source).join('')
142142
* @param {string} str
143143
*/
144144
export const escapeHTML = str =>
145-
str.replace(/[&<>'"]/g, r => ({
145+
str.replace(/[&<>'"]/g, r => /** @type {string} */ ({
146146
'&': '&amp;',
147147
'<': '&lt;',
148148
'>': '&gt;',
149149
"'": '&#39;',
150150
'"': '&quot;'
151-
}[r] || r))
151+
}[r]))
152152

153153
/**
154154
* Reverse of `escapeHTML`
155155
*
156156
* @param {string} str
157157
*/
158158
export const unescapeHTML = str =>
159-
str.replace(/&amp;|&lt;|&gt;|&#39;|&quot;/g, r => ({
159+
str.replace(/&amp;|&lt;|&gt;|&#39;|&quot;/g, r => /** @type {string} */ ({
160160
'&amp;': '&',
161161
'&lt;': '<',
162162
'&gt;': '>',
163163
'&#39;': "'",
164164
'&quot;': '"'
165-
}[r] || r))
165+
}[r]))

0 commit comments

Comments
 (0)