blob: 34241c9aec146618e8c711865e5cb1f72be8b9e6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// Copyright Epic Games, Inc. All Rights Reserved.
// Tiny shared helpers used across the trace-viewer modules.
// Escape characters that have special meaning inside an HTML context (text or
// attribute) so that user-supplied strings can be safely interpolated into
// .innerHTML / template literals. Coerces the input to string first so callers
// don't have to.
export function escapeHtml(s) {
return String(s).replace(/[&<>"']/g, (c) => ({
"&": "&",
"<": "<",
">": ">",
"\"": """,
"'": "'",
}[c]));
}
|