diff --git a/src/shared/utils/avatar.js b/src/shared/utils/avatar.js index bf1af67b..f24bb76e 100644 --- a/src/shared/utils/avatar.js +++ b/src/shared/utils/avatar.js @@ -1,4 +1,4 @@ -import { replaceBioSymbols } from './common'; +import { replaceBioSymbols } from './base/string'; import { useAuthStore } from '../../stores'; /** diff --git a/src/shared/utils/base/string.js b/src/shared/utils/base/string.js index 1640fcc6..2a01f951 100644 --- a/src/shared/utils/base/string.js +++ b/src/shared/utils/base/string.js @@ -99,11 +99,58 @@ function changeLogRemoveLinks(text) { return text.replace(/([^!])\[[^\]]+\]\([^)]+\)/g, '$1'); } +/** + * + * @param {string} text + * @returns {string} + */ +function replaceBioSymbols(text) { + if (typeof text !== 'string') { + return ''; + } + const symbolList = { + '@': '@', + '#': '#', + $: '$', + '%': '%', + '&': '&', + '=': '=', + '+': '+', + '/': '⁄', + '\\': '\', + ';': ';', + ':': '˸', + ',': '‚', + '?': '?', + '!': 'ǃ', + '"': '"', + '<': '≺', + '>': '≻', + '.': '․', + '^': '^', + '{': '{', + '}': '}', + '[': '[', + ']': ']', + '(': '(', + ')': ')', + '|': '|', + '*': '∗' + }; + let newText = text; + for (const key in symbolList) { + const regex = new RegExp(symbolList[key], 'g'); + newText = newText.replace(regex, key); + } + return newText.replace(/ {1,}/g, ' ').trimRight(); +} + export { escapeTag, escapeTagRecursive, textToHex, commaNumber, localeIncludes, - changeLogRemoveLinks + changeLogRemoveLinks, + replaceBioSymbols }; diff --git a/src/shared/utils/common.js b/src/shared/utils/common.js index 132855db..a53b8e6d 100644 --- a/src/shared/utils/common.js +++ b/src/shared/utils/common.js @@ -10,9 +10,9 @@ import { useSearchStore, useWorldStore } from '../../stores'; +import { escapeTag, replaceBioSymbols } from './base/string'; import { AppDebug } from '../../service/appConfig.js'; import { compareUnityVersion } from './avatar'; -import { escapeTag } from './base/string'; import { miscRequest } from '../../api'; /** @@ -345,52 +345,6 @@ function buildTreeData(json) { return node; } -/** - * - * @param {string} text - * @returns {string} - */ -function replaceBioSymbols(text) { - if (typeof text !== 'string') { - return ''; - } - const symbolList = { - '@': '@', - '#': '#', - $: '$', - '%': '%', - '&': '&', - '=': '=', - '+': '+', - '/': '⁄', - '\\': '\', - ';': ';', - ':': '˸', - ',': '‚', - '?': '?', - '!': 'ǃ', - '"': '"', - '<': '≺', - '>': '≻', - '.': '․', - '^': '^', - '{': '{', - '}': '}', - '[': '[', - ']': ']', - '(': '(', - ')': ')', - '|': '|', - '*': '∗' - }; - let newText = text; - for (const key in symbolList) { - const regex = new RegExp(symbolList[key], 'g'); - newText = newText.replace(regex, key); - } - return newText.replace(/ {1,}/g, ' ').trimRight(); -} - /** * * @param {string} link diff --git a/src/shared/utils/instance.js b/src/shared/utils/instance.js index 12d0ee2e..80d1bd2d 100644 --- a/src/shared/utils/instance.js +++ b/src/shared/utils/instance.js @@ -1,5 +1,5 @@ import { instanceRequest } from '../../api'; -import { parseLocation } from './location'; +import { parseLocation } from './locationParser'; /** *