more low-hanging fruits
This commit is contained in:
parent
4f82709bf2
commit
b2dca4a3f6
20 changed files with 45 additions and 45 deletions
|
|
@ -3,7 +3,7 @@ import emojis from '@kazvmoe-infra/unicode-emoji-json/data-by-group.json' with {
|
|||
type: 'json',
|
||||
}
|
||||
|
||||
Object.keys(emojis).map((k) => {
|
||||
Object.keys(emojis).forEach((k) => {
|
||||
emojis[k].forEach((e) => {
|
||||
delete e.unicode_version
|
||||
delete e.emoji_version
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ const registration = {
|
|||
})
|
||||
},
|
||||
replaceNewlines(str) {
|
||||
return str.replace(/\s*\n\s*/g, ' \n')
|
||||
return str.replaceAll('\s*\n\s*', ' \n')
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ export default {
|
|||
}
|
||||
|
||||
// Processor to use with html_tree_converter
|
||||
const processItem = (item, index, array, what) => {
|
||||
const processItem = (item, index, array) => {
|
||||
// Handle text nodes - just add emoji
|
||||
if (typeof item === 'string') {
|
||||
const emptyText = item.trim() === ''
|
||||
|
|
@ -281,7 +281,7 @@ export default {
|
|||
|
||||
// Processor for back direction (for finding "last" stuff, just easier this way)
|
||||
let encounteredTextReverse = false
|
||||
const processItemReverse = (item, index, array, what) => {
|
||||
const processItemReverse = (item, index, array) => {
|
||||
// Handle text nodes - just add emoji
|
||||
if (typeof item === 'string') {
|
||||
const emptyText = item.trim() === ''
|
||||
|
|
@ -479,7 +479,7 @@ export default {
|
|||
>
|
||||
{this.collapse
|
||||
? pass2.map((x) => {
|
||||
if (typeof x === 'string') return x.replace(/\n/g, ' ')
|
||||
if (typeof x === 'string') return x.replaceAll('\n', ' ')
|
||||
if (!Array.isArray(x)) return x
|
||||
return x.map((y) => (y.type === 'br' ? ' ' : y))
|
||||
})
|
||||
|
|
@ -547,8 +547,8 @@ export const preProcessPerLine = (html, greentext) => {
|
|||
(string.includes('>') || string.includes('<'))
|
||||
) {
|
||||
const cleanedString = string
|
||||
.replace(/<[^>]+?>/gi, '') // remove all tags
|
||||
.replace(/@\w+/gi, '') // remove mentions (even failed ones)
|
||||
.replaceAll(/<[^>]+?>/gi, '') // remove all tags
|
||||
.replaceAll(/@\w+/gi, '') // remove mentions (even failed ones)
|
||||
.trim()
|
||||
if (cleanedString.startsWith('>')) {
|
||||
return `<span class='greentext'>${string}</span>`
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ const EmojiTab = {
|
|||
sortPackFiles(nameOfPack) {
|
||||
// Sort by key
|
||||
const sorted = Object.keys(this.knownPacks[nameOfPack].files)
|
||||
.sort()
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.reduce((acc, key) => {
|
||||
if (key.length === 0) return acc
|
||||
acc[key] = this.knownPacks[nameOfPack].files[key]
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ export default {
|
|||
[
|
||||
'admin_dash',
|
||||
'temp_overrides',
|
||||
...this.canonPath.map((p) => p.replace(/\./g, '_DOT_')),
|
||||
...this.canonPath.map((p) => p.replaceAll('\.', '_DOT_')),
|
||||
'label',
|
||||
].join('.'),
|
||||
)
|
||||
|
|
@ -198,7 +198,7 @@ export default {
|
|||
[
|
||||
'admin_dash',
|
||||
'temp_overrides',
|
||||
...this.canonPath.map((p) => p.replace(/\./g, '_DOT_')),
|
||||
...this.canonPath.map((p) => p.replaceAll('\.', '_DOT_')),
|
||||
'description',
|
||||
].join('.'),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ const AppearanceTab = {
|
|||
|
||||
const result = {
|
||||
name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
|
||||
key: `style.${variant.toLowerCase().replace(/ /g, '_')}`,
|
||||
key: `style.${variant.toLowerCase().replaceAll(' ', '_')}`,
|
||||
bg,
|
||||
fg,
|
||||
text,
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ export default {
|
|||
return useInterfaceStore().themeDataUsed
|
||||
},
|
||||
shadowsAvailable() {
|
||||
return Object.keys(DEFAULT_SHADOWS).sort()
|
||||
return Object.keys(DEFAULT_SHADOWS).sort((a, b) => a.localeCompare(b))
|
||||
},
|
||||
currentShadowOverriden: {
|
||||
get() {
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ const StatusBody = {
|
|||
return this.status.attachments.map((file) => file.type)
|
||||
},
|
||||
collapsedStatus() {
|
||||
return this.status.raw_html.replace(/(\n|<br\s?\/?>)/g, ' ')
|
||||
return this.status.raw_html.replaceAll('(\n|<br\s?\/?>)', ' ')
|
||||
},
|
||||
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||
},
|
||||
|
|
@ -168,7 +168,7 @@ const StatusBody = {
|
|||
.filter((mention) => !mention.notifying)
|
||||
.forEach((mention) => {
|
||||
const { content, url } = mention
|
||||
const cleanedString = content.replace(/<[^>]+?>/gi, '') // remove all tags
|
||||
const cleanedString = content.replaceAll(/<[^>]+?>/gi, '') // remove all tags
|
||||
if (!cleanedString.startsWith('@')) return
|
||||
const handle = cleanedString.slice(1)
|
||||
const host = url.replace(/^https?:\/\//, '').replace(/\/.+?$/, '')
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
escapedNewBio() {
|
||||
return ldEscape(this.newBio).replace(/\n/g, '<br>')
|
||||
return ldEscape(this.newBio).replaceAll('\n', '<br>')
|
||||
},
|
||||
somethingToSave() {
|
||||
if (this.newName !== this.user.name_unescaped) return true
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ export const parseUser = (data) => {
|
|||
})
|
||||
output.fields_text = data.fields.map((field) => {
|
||||
return {
|
||||
name: unescape(field.name.replace(/<[^>]*>/g, '')),
|
||||
value: unescape(field.value.replace(/<[^>]*>/g, '')),
|
||||
name: unescape(field.name.replaceAll('<[^>]*>', '')),
|
||||
value: unescape(field.value.replaceAll('<[^>]*>', '')),
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { capitalize } from 'lodash'
|
|||
function humanizeErrors(errors) {
|
||||
return Object.entries(errors).reduce((errs, [k, val]) => {
|
||||
const message = val.reduce((acc, message) => {
|
||||
const key = capitalize(k.replace(/_/g, ' '))
|
||||
const key = capitalize(k.replaceAll('_', ' '))
|
||||
return acc + [key, message].join(' ') + '. '
|
||||
}, '')
|
||||
return [...errs, message]
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export const createStyleSheet = (id, priority = 1000) => {
|
|||
addRule(rule) {
|
||||
let newRule = rule
|
||||
if (!CSS.supports?.('backdrop-filter', 'blur()')) {
|
||||
newRule = newRule.replace(/backdrop-filter:[^;]+;/g, '') // Remove backdrop-filter
|
||||
newRule = newRule.replaceAll('backdrop-filter:[^;]+;', '') // Remove backdrop-filter
|
||||
}
|
||||
|
||||
if (newRule.startsWith('::-webkit')) {
|
||||
|
|
@ -44,7 +44,7 @@ export const createStyleSheet = (id, priority = 1000) => {
|
|||
}
|
||||
|
||||
this.rules.push(
|
||||
newRule.replace(/var\(--shadowFilter\)[^;]*;/g, ''), // Remove shadowFilter references
|
||||
newRule.replaceAll('var\(--shadowFilter\)[^;]*;', ''), // Remove shadowFilter references
|
||||
)
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* global process */
|
||||
function urlBase64ToUint8Array(base64String) {
|
||||
const padding = '='.repeat((4 - (base64String.length % 4)) % 4)
|
||||
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/')
|
||||
const base64 = (base64String + padding).replaceAll('-', '+').replace(/_/g, '/')
|
||||
|
||||
const rawData = window.atob(base64)
|
||||
return Uint8Array.from([...rawData].map((char) => char.codePointAt(0)))
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ export const generatePreset = (input) => {
|
|||
return composePreset(
|
||||
colors,
|
||||
generateRadii(input),
|
||||
generateShadows(input, colors.theme.colors, colors.mod),
|
||||
generateShadows(input, colors.theme.colors),
|
||||
generateFonts(input),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ const highlightStyle = (prefs) => {
|
|||
|
||||
const highlightClass = (user) => {
|
||||
return (
|
||||
'USER____' + user.screen_name?.replace(/\./g, '_').replace(/@/g, '_AT_')
|
||||
'USER____' + user.screen_name?.replaceAll('\.', '_').replace(/@/g, '_AT_')
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ export const useEmojiStore = defineStore('emoji', {
|
|||
.then((allPacks) => {
|
||||
// Sort by key
|
||||
return Object.keys(allPacks)
|
||||
.sort()
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.reduce((acc, key) => {
|
||||
if (key.length === 0) return acc
|
||||
acc[key] = allPacks[key]
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
return { name: x.variant, ...cleanDirectives }
|
||||
})
|
||||
.forEach((palette) => {
|
||||
const key = 'style.' + palette.name.toLowerCase().replace(/ /g, '_')
|
||||
const key = 'style.' + palette.name.toLowerCase().replaceAll(' ', '_')
|
||||
if (!firstStylePaletteName) firstStylePaletteName = key
|
||||
palettesIndex[key] = () => Promise.resolve(palette)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
|
||||
})
|
||||
|
||||
it('unescapes everything as needed', () => {
|
||||
|
|
@ -67,7 +67,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
it('replaces mention with mentionsline', () => {
|
||||
|
|
@ -83,7 +83,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(
|
||||
compwrap(p(mentionsLine(1), ' how are you doing today?')),
|
||||
)
|
||||
})
|
||||
|
|
@ -116,7 +116,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
it('Does not touch links if link handling is disabled', () => {
|
||||
|
|
@ -211,7 +211,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
it("Doesn't add nonexistent emoji to post", () => {
|
||||
|
|
@ -228,7 +228,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
|
||||
})
|
||||
|
||||
it('Greentext + last mentions', () => {
|
||||
|
|
@ -279,7 +279,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
it('buggy example/hashtags', () => {
|
||||
|
|
@ -315,7 +315,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
it('rich contents of a mention are handled properly', () => {
|
||||
|
|
@ -365,8 +365,8 @@ describe('RichContent', () => {
|
|||
expect(
|
||||
wrapper
|
||||
.html()
|
||||
.replace(/\n/g, '')
|
||||
.replace(/<!--.*?-->/g, ''),
|
||||
.replaceAll('\n', '')
|
||||
.replaceAll('<!--.*?-->', ''),
|
||||
).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
|
|
@ -438,8 +438,8 @@ describe('RichContent', () => {
|
|||
expect(
|
||||
wrapper
|
||||
.html()
|
||||
.replace(/\n/g, '')
|
||||
.replace(/<!--.*?-->/g, ''),
|
||||
.replaceAll('\n', '')
|
||||
.replaceAll('<!--.*?-->', ''),
|
||||
).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
|
|
@ -484,7 +484,7 @@ describe('RichContent', () => {
|
|||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
|
||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||
})
|
||||
|
||||
it.skip('[INFORMATIVE] Performance testing, 10 000 simple posts', () => {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ describe('Statuses module', () => {
|
|||
showImmediately: true,
|
||||
timeline: 'public',
|
||||
})
|
||||
expect(state.timelines.public.maxId).to.eql('1')
|
||||
expect(state.timelines.public.maxId).to.equal('1')
|
||||
|
||||
mutations.addNewStatuses(state, {
|
||||
statuses: [secondStatus],
|
||||
|
|
@ -120,7 +120,7 @@ describe('Statuses module', () => {
|
|||
secondStatus,
|
||||
status,
|
||||
])
|
||||
expect(state.timelines.public.maxId).to.eql('1')
|
||||
expect(state.timelines.public.maxId).to.equal('1')
|
||||
})
|
||||
|
||||
it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => {
|
||||
|
|
@ -340,7 +340,7 @@ describe('Statuses module', () => {
|
|||
expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true)
|
||||
expect(
|
||||
state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id,
|
||||
).to.eql('me')
|
||||
).to.equal('me')
|
||||
})
|
||||
|
||||
it('adds a new reaction', () => {
|
||||
|
|
@ -362,7 +362,7 @@ describe('Statuses module', () => {
|
|||
expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true)
|
||||
expect(
|
||||
state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id,
|
||||
).to.eql('me')
|
||||
).to.equal('me')
|
||||
})
|
||||
|
||||
it('decreases count in existing reaction', () => {
|
||||
|
|
@ -429,8 +429,8 @@ describe('Statuses module', () => {
|
|||
mutations.showNewStatuses(state, { timeline: 'public' })
|
||||
|
||||
expect(state.timelines.public.visibleStatuses.length).to.eql(2)
|
||||
expect(state.timelines.public.minVisibleId).to.eql('10')
|
||||
expect(state.timelines.public.minId).to.eql('10')
|
||||
expect(state.timelines.public.minVisibleId).to.equal('10')
|
||||
expect(state.timelines.public.minId).to.equal('10')
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ const run = () => {
|
|||
|
||||
// Sort by key
|
||||
const sorted = Object.keys(emojisObject)
|
||||
.sort()
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.reduce((acc, key) => {
|
||||
if (key.length === 0) return acc
|
||||
acc[key] = emojisObject[key]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue