-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
38 lines (35 loc) · 976 Bytes
/
Copy pathutil.js
File metadata and controls
38 lines (35 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/** Mappings between characters that need to be escaped in HTML code (to prevent cross-site
scripting attacks) and their corresponding escape sequences, i.e. HTML character entities.
@readonly
*/
const ESCAPE_MAP = Object.freeze({
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
});
/** Escapes a string so that any HTML code contained within it is converted into plain
text.
@param {string} input The text to make safe.
*/
function escapeHTML(input) {
'use strict';
return String(input).replace(/[&<>"']/g, function (match) {
return ESCAPE_MAP[match];
});
}
/** Escapes a string so that any regular expression meta characters are preceded by a backslash.
@param {string} string The text to escape.
*/
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function findCheckedRadioButton(buttons) {
'use strict';
for (let button of buttons) {
if (button.checked) {
return button.value;
}
}
}