sync
This commit is contained in:
@ -47,7 +47,8 @@ function getStorageKey(lgid) {
|
||||
|
||||
async function doRefreshLgres(template = '') {
|
||||
const lgid = getCurrentLgId();
|
||||
const r = await get(`language/${lgid}${template}`);
|
||||
const url = template.length > 0 ? template.replace('{lgid}', lgid) : `language/${lgid}`;
|
||||
const r = await get(url);
|
||||
const dict = await r.json();
|
||||
localStorage.setItem(getStorageKey(lgid), JSON.stringify(dict));
|
||||
return dict;
|
||||
|
3
lib/utility/strings.d.ts
vendored
3
lib/utility/strings.d.ts
vendored
@ -3,4 +3,5 @@ export function contains(s: string, key: string | any, ignoreCase?: boolean): bo
|
||||
export function endsWith(s: string, suffix: string): boolean
|
||||
export function padStart(s: string, num: Number, char: string): boolean
|
||||
export function formatUrl(msg: string): string
|
||||
export function escapeHtml(text: string): string
|
||||
export function escapeHtml(text: string): string
|
||||
export function escapeEmoji(text: string): string
|
@ -64,4 +64,16 @@ export function escapeHtml(text) {
|
||||
.replaceAll('\r\n', '<br/>')
|
||||
.replaceAll('\n', '<br/>')
|
||||
.replaceAll(' ', ' ');
|
||||
}
|
||||
|
||||
export function escapeEmoji(text) {
|
||||
if (text == null) {
|
||||
return '';
|
||||
}
|
||||
if (typeof text !== 'string') {
|
||||
text = String(text);
|
||||
}
|
||||
return text
|
||||
.replace(/(=[A-Fa-f0-9]{2}){4}/g, s => decodeURIComponent(s.replaceAll('=', '%')))
|
||||
.replace(/&#x([0-9a-fA-F]{2,6});/g, (_, h) => String.fromCodePoint(parseInt(h, 16)));
|
||||
}
|
Reference in New Issue
Block a user