blob: 05a283c6e1804c73e829968e0c9b6c9fd9b29c8c [file] [log] [blame]
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02001// Escapes username from HTML generated by the Community Console.
2export function escapeUsername(username) {
3 var quoteRegex = /"/g;
4 var commentRegex = /<!---->/g;
5 return username.replace(quoteRegex, '\\"').replace(commentRegex, '');
6}
7
8// Retrieves authuser from the data-startup attribute.
9export function getAuthUser() {
10 var startup =
11 JSON.parse(document.querySelector('html').getAttribute('data-startup'));
12 return startup?.[2]?.[1] || '0';
13}