refactor: substr -> substring (#11273)

This commit is contained in:
okayurisotto 2023-07-14 07:59:54 +09:00 committed by GitHub
parent af30959cb9
commit c0dbc3b53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 38 additions and 38 deletions

View File

@ -31,7 +31,7 @@ function greet() {
console.log(themeColor(' | |_|___ ___| |_ ___ _ _ '));
console.log(themeColor(' | | | | |_ -|_ -| \'_| -_| | |'));
console.log(themeColor(' |_|_|_|_|___|___|_,_|___|_ |'));
console.log(' ' + chalk.gray(v) + themeColor(' |___|\n'.substr(v.length)));
console.log(' ' + chalk.gray(v) + themeColor(' |___|\n'.substring(v.length)));
//#endregion
console.log(' Misskey is an open-source decentralized microblogging platform.');

View File

@ -254,7 +254,7 @@ export default abstract class Chart<T extends Schema> {
private convertRawRecord(x: RawRecord<T>): KVs<T> {
const kvs = {} as Record<string, number>;
for (const k of Object.keys(x).filter((k) => k.startsWith(COLUMN_PREFIX)) as (keyof Columns<T>)[]) {
kvs[(k as string).substr(COLUMN_PREFIX.length).split(COLUMN_DELIMITER).join('.')] = x[k] as unknown as number;
kvs[(k as string).substring(COLUMN_PREFIX.length).split(COLUMN_DELIMITER).join('.')] = x[k] as unknown as number;
}
return kvs as KVs<T>;
}

View File

@ -4,7 +4,7 @@ export type Acct = {
};
export function parse(acct: string): Acct {
if (acct.startsWith('@')) acct = acct.substr(1);
if (acct.startsWith('@')) acct = acct.substring(1);
const split = acct.split('@', 2);
return { username: split[0], host: split[1] ?? null };
}

View File

@ -25,8 +25,8 @@
<MkDriveFileThumbnail :class="$style.thumbnail" :file="file" fit="contain"/>
<p :class="$style.name">
<span>{{ file.name.lastIndexOf('.') != -1 ? file.name.substr(0, file.name.lastIndexOf('.')) : file.name }}</span>
<span v-if="file.name.lastIndexOf('.') != -1" style="opacity: 0.5;">{{ file.name.substr(file.name.lastIndexOf('.')) }}</span>
<span>{{ file.name.lastIndexOf('.') != -1 ? file.name.substring(0, file.name.lastIndexOf('.')) : file.name }}</span>
<span v-if="file.name.lastIndexOf('.') != -1" style="opacity: 0.5;">{{ file.name.substring(file.name.lastIndexOf('.')) }}</span>
</p>
</div>
</div>

View File

@ -1,6 +1,6 @@
<template>
<component
:is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target"
:is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel" :target="target"
:title="url"
>
<slot></slot>

View File

@ -564,7 +564,7 @@ async function onPaste(ev: ClipboardEvent) {
return;
}
quoteId = paste.substr(url.length).match(/^\/notes\/(.+?)\/?$/)[1];
quoteId = paste.substring(url.length).match(/^\/notes\/(.+?)\/?$/)[1];
});
}
}

View File

@ -6,7 +6,7 @@
:class="[$style.root, { [$style.reacted]: note.myReaction == reaction, [$style.canToggle]: canToggle, [$style.large]: defaultStore.state.largeNoteReactions }]"
@click="toggleReaction()"
>
<MkReactionIcon :class="$style.icon" :reaction="reaction" :emojiUrl="note.reactionEmojis[reaction.substr(1, reaction.length - 2)]"/>
<MkReactionIcon :class="$style.icon" :reaction="reaction" :emojiUrl="note.reactionEmojis[reaction.substring(1, reaction.length - 1)]"/>
<span :class="$style.count">{{ count }}</span>
</button>
</template>

View File

@ -32,7 +32,7 @@
</div>
</template>
<div v-else>
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substring(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
<div v-if="thumbnail" :class="$style.thumbnail" :style="`background-image: url('${thumbnail}')`">
</div>
<article :class="$style.body">

View File

@ -88,7 +88,7 @@ onMounted(() => {
user = props.q;
} else {
const query = props.q.startsWith('@') ?
Acct.parse(props.q.substr(1)) :
Acct.parse(props.q.substring(1)) :
{ userId: props.q };
os.api('users/show', query).then(res => {

View File

@ -18,7 +18,7 @@ const props = defineProps<{
useOriginalSize?: boolean;
}>();
const customEmojiName = computed(() => (props.name[0] === ':' ? props.name.substr(1, props.name.length - 2) : props.name).replace('@.', ''));
const customEmojiName = computed(() => (props.name[0] === ':' ? props.name.substring(1, props.name.length - 1) : props.name).replace('@.', ''));
const isLocal = computed(() => !props.host && (customEmojiName.value.endsWith('@.') || !customEmojiName.value.includes('@')));
const rawUrl = computed(() => {

View File

@ -11,13 +11,13 @@ export default function(props: { src: string; tag?: string; textTag?: string; },
parsed.push(str);
break;
} else {
if (nextBracketOpen > 0) parsed.push(str.substr(0, nextBracketOpen));
if (nextBracketOpen > 0) parsed.push(str.substring(0, nextBracketOpen));
parsed.push({
arg: str.substring(nextBracketOpen + 1, nextBracketClose),
});
}
str = str.substr(nextBracketClose + 1);
str = str.substring(nextBracketClose + 1);
}
return h(props.tag ?? 'span', parsed.map(x => typeof x === 'string' ? (props.textTag ? h(props.textTag, x) : x) : slots[x.arg]()));

View File

@ -85,7 +85,7 @@ onMounted(() => {
connection.on('stats', onStats);
connection.on('statsLog', onStatsLog);
connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: 100,
});
});

View File

@ -156,7 +156,7 @@ onMounted(async () => {
nextTick(() => {
queueStatsConnection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: 100,
});
});

View File

@ -106,7 +106,7 @@ onMounted(() => {
connection.on('stats', onStats);
connection.on('statsLog', onStatsLog);
connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: 200,
});
});

View File

@ -65,7 +65,7 @@ export class Autocomplete {
*/
private onInput() {
const caretPos = this.textarea.selectionStart;
const text = this.text.substr(0, caretPos).split('\n').pop()!;
const text = this.text.substring(0, caretPos).split('\n').pop()!;
const mentionIndex = text.lastIndexOf('@');
const hashtagIndex = text.lastIndexOf('#');
@ -91,7 +91,7 @@ export class Autocomplete {
let opened = false;
if (isMention) {
const username = text.substr(mentionIndex + 1);
const username = text.substring(mentionIndex + 1);
if (username !== '' && username.match(/^[a-zA-Z0-9_]+$/)) {
this.open('user', username);
opened = true;
@ -102,7 +102,7 @@ export class Autocomplete {
}
if (isHashtag && !opened) {
const hashtag = text.substr(hashtagIndex + 1);
const hashtag = text.substring(hashtagIndex + 1);
if (!hashtag.includes(' ')) {
this.open('hashtag', hashtag);
opened = true;
@ -110,7 +110,7 @@ export class Autocomplete {
}
if (isEmoji && !opened) {
const emoji = text.substr(emojiIndex + 1);
const emoji = text.substring(emojiIndex + 1);
if (!emoji.includes(' ')) {
this.open('emoji', emoji);
opened = true;
@ -118,7 +118,7 @@ export class Autocomplete {
}
if (isMfmTag && !opened) {
const mfmTag = text.substr(mfmTagIndex + 1);
const mfmTag = text.substring(mfmTagIndex + 1);
if (!mfmTag.includes(' ')) {
this.open('mfmTag', mfmTag.replace('[', ''));
opened = true;
@ -208,9 +208,9 @@ export class Autocomplete {
if (type === 'user') {
const source = this.text;
const before = source.substr(0, caret);
const before = source.substring(0, caret);
const trimmedBefore = before.substring(0, before.lastIndexOf('@'));
const after = source.substr(caret);
const after = source.substring(caret);
const acct = value.host === null ? value.username : `${value.username}@${toASCII(value.host)}`;
@ -226,9 +226,9 @@ export class Autocomplete {
} else if (type === 'hashtag') {
const source = this.text;
const before = source.substr(0, caret);
const before = source.substring(0, caret);
const trimmedBefore = before.substring(0, before.lastIndexOf('#'));
const after = source.substr(caret);
const after = source.substring(caret);
// 挿入
this.text = `${trimmedBefore}#${value} ${after}`;
@ -242,9 +242,9 @@ export class Autocomplete {
} else if (type === 'emoji') {
const source = this.text;
const before = source.substr(0, caret);
const before = source.substring(0, caret);
const trimmedBefore = before.substring(0, before.lastIndexOf(':'));
const after = source.substr(caret);
const after = source.substring(caret);
// 挿入
this.text = trimmedBefore + value + after;
@ -258,9 +258,9 @@ export class Autocomplete {
} else if (type === 'mfmTag') {
const source = this.text;
const before = source.substr(0, caret);
const before = source.substring(0, caret);
const trimmedBefore = before.substring(0, before.lastIndexOf('$'));
const after = source.substr(caret);
const after = source.substring(caret);
// 挿入
this.text = `${trimmedBefore}$[${value} ]${after}`;

View File

@ -5,7 +5,7 @@ export async function genSearchQuery(v: any, q: string) {
let host: string;
let userId: string;
if (q.split(' ').some(x => x.startsWith('@'))) {
for (const at of q.split(' ').filter(x => x.startsWith('@')).map(x => x.substr(1))) {
for (const at of q.split(' ').filter(x => x.startsWith('@')).map(x => x.substring(1))) {
if (at.includes('.')) {
if (at === localHost || at === '.') {
host = null;

View File

@ -18,7 +18,7 @@ export async function lookup(router?: Router) {
}
if (query.startsWith('#')) {
_router.push(`/tags/${encodeURIComponent(query.substr(1))}`);
_router.push(`/tags/${encodeURIComponent(query.substring(1))}`);
return;
}

View File

@ -35,7 +35,7 @@ export const fromThemeString = (str?: string) : ThemeValue => {
} else if (str.startsWith('"')) {
return {
type: 'css',
value: str.substr(1).trim(),
value: str.substring(1).trim(),
};
} else {
return str;

View File

@ -98,7 +98,7 @@ function compile(theme: Theme): Record<string, string> {
function getColor(val: string): tinycolor.Instance {
// ref (prop)
if (val[0] === '@') {
return getColor(theme.props[val.substr(1)]);
return getColor(theme.props[val.substring(1)]);
}
// ref (const)
@ -109,7 +109,7 @@ function compile(theme: Theme): Record<string, string> {
// func
else if (val[0] === ':') {
const parts = val.split('<');
const func = parts.shift().substr(1);
const func = parts.shift().substring(1);
const arg = parseFloat(parts.shift());
const color = getColor(parts.join('<'));

View File

@ -124,7 +124,7 @@ connection.on('stats', onStats);
connection.on('statsLog', onStatsLog);
connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: 1,
});

View File

@ -100,7 +100,7 @@ onMounted(() => {
props.connection.on('stats', onStats);
props.connection.on('statsLog', onStatsLog);
props.connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
});
});

View File

@ -70,7 +70,7 @@ onMounted(() => {
props.connection.on('stats', onStats);
props.connection.on('statsLog', onStatsLog);
props.connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
});
});

View File

@ -4,7 +4,7 @@ export type Acct = {
};
export function parse(acct: string): Acct {
if (acct.startsWith('@')) acct = acct.substr(1);
if (acct.startsWith('@')) acct = acct.substring(1);
const split = acct.split('@', 2);
return { username: split[0], host: split[1] || null };
}