added function to remove control characters from names

This commit is contained in:
2021-11-22 16:37:00 +01:00
parent 6f6834e7ea
commit e6d3a94105
4 changed files with 28 additions and 6 deletions

View File

@@ -70,7 +70,8 @@ export const constructAvatarUrl = (hash, size) => {
export const sortObjectValue = (obj, direction = 'asc') => {
const sortable = []
for (let key in obj) {
sortable.push([key, obj[key]])}
sortable.push([key, obj[key]])
}
if (direction === 'asc') {
sortable.sort((a, b) => {
@@ -101,3 +102,12 @@ export const scrollToPos = (pos = 0) => {
behavior: 'smooth'
})
}
export const StripControlCodes = (str = '') => {
const regexpControl = /\p{C}/gu;
return str.replace(regexpControl, '')
}
export const ProcessName = (str = '') => {
return StripControlCodes(str).trim()
}

View File

@@ -32,7 +32,9 @@ import {
setTitle,
sortObjectValue,
truncate,
scrollToPos
scrollToPos,
StripControlCodes,
ProcessName
} from "./Utils";
export {
@@ -68,5 +70,7 @@ export {
CreatePlayersArray,
GetMatches,
LoadMoreMatchesExplore,
scrollToPos
scrollToPos,
StripControlCodes,
ProcessName
}

View File

@@ -134,7 +134,7 @@ import {
FormatFullDate,
GetMatchDetails,
GoToLink,
LoadImage
LoadImage, ProcessName
} from "../utils";
import {useStore} from "vuex";
import {useRoute} from 'vue-router'
@@ -173,6 +173,11 @@ export default {
})
data.matchDetails = store.state.matchDetails
data.matchDetails.stats.forEach(p => {
p.player.name = ProcessName(p.player.name)
})
data.stats = data.matchDetails.stats
data.score = data.matchDetails.score

View File

@@ -157,7 +157,8 @@ import {
SaveLastVisitedToLocalStorage,
scrollToPos,
setTitle,
TrackMe
TrackMe,
ProcessName
} from "../utils";
import {FOOTER_HEIGHT, NAV_HEIGHT} from "@/constants";
import MatchesTable from "@/components/MatchesTable";
@@ -189,7 +190,7 @@ export default {
tie: 0,
total: 0
},
playerMeta: {}
playerMeta: {},
})
onBeforeMount(() => {
@@ -249,6 +250,8 @@ export default {
if (res === 200 && resData) {
if (resData.steamid64 !== store.state.playerDetails.steamid64 || reset) {
resData.name = ProcessName(resData.name)
store.commit('resetPlayerDetails')
store.commit({
type: 'changePlayerDetails',