Skip to content

Commit

Permalink
Replace: String.substr() -> String.substring()
Browse files Browse the repository at this point in the history
  • Loading branch information
fs5m8 committed Dec 26, 2022
1 parent 8a37c22 commit eb40267
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/boot/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function greet() {
console.log(' | _ |___ ___|_|___ ___ ___| |_ ___ _ _ ');
console.log(' | | _| -_| | . | |_ -| \'_| -_| | |');
console.log(' |__|__|_| |___|_|___|_|_|___|_,_|___|_ |');
console.log(' ' + chalk.gray(v) + (' |___|\n'.substr(v.length)));
console.log(' ' + chalk.gray(v) + (' |___|\n'.substring(v.length)));
//#endregion

console.log(' Areionskey is maintained by @fs5m8, @atsu1125, and @yui87.');
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/admin/views/dashboard.ap-log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default Vue.extend({
this.connection.on('log', this.onLog);
this.connection.on('logs', this.onLogs);
this.connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: 50
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/admin/views/dashboard.cpu-memory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default Vue.extend({
this.connection.on('stats', this.onStats);
this.connection.on('statsLog', this.onStatsLog);
this.connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: 200
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/admin/views/dashboard.queue-charts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default Vue.extend({
connection.on('stats', this.onStats);
connection.on('statsLog', this.onStatsLog);
connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: limit
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/admin/views/queue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default Vue.extend({
this.connection = this.$root.stream.useSharedConnection('queueStats');
this.connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
id: Math.random().toString().substring(2, 10),
length: this.chartLimit
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/scripts/gen-search-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/scripts/post-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export default (opts) => ({
return;
}

this.quoteId = paste.substr(url.length).match(/^\/notes\/(.+?)\/?$/)[1];
this.quoteId = paste.substring(url.length).match(/^\/notes\/(.+?)\/?$/)[1];
});
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/common/scripts/room/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export class Room {
(child.material as THREE.MeshStandardMaterial).name &&
(child.material as THREE.MeshStandardMaterial).name === 'Carpet'
) {
const colorHex = parseInt(this.roomInfo.carpetColor.substr(1), 16);
const colorHex = parseInt(this.roomInfo.carpetColor.substring(1), 16);
(child.material as THREE.MeshStandardMaterial).color.setHex(colorHex);
}
});
Expand All @@ -457,7 +457,7 @@ export class Room {

if (val == null) continue;

const colorHex = parseInt(val.substr(1), 16);
const colorHex = parseInt(val.substring(1), 16);
(child.material as THREE.MeshStandardMaterial).color.setHex(colorHex);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/scripts/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function search(v: any, q: string) {
}

if (q.startsWith('#')) {
v.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
v.$router.push(`/tags/${encodeURIComponent(q.substring(1))}`);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/scripts/should-mute-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function(me, settings, note) {
const includesMutedWords = (text: string) =>
text
? settings.mutedWords.some(q => q.length > 0 && !q.some(word =>
word.startsWith('/') && word.endsWith('/') ? !(new RegExp(word.substr(1, word.length - 2)).test(text)) : !text.includes(word)))
word.startsWith('/') && word.endsWith('/') ? !(new RegExp(word.substring(1, word.length - 1)).test(text)) : !text.includes(word)))
: false;

return (
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/common/scripts/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Pool {
this.channel = channel;
this.stream = stream;

this.id = Math.random().toString().substr(2, 8);
this.id = Math.random().toString().substring(2, 10);

this.stream.on('_disconnected_', this.onStreamDisconnected);
}
Expand Down Expand Up @@ -279,7 +279,7 @@ class NonSharedConnection extends Connection {
super(stream, channel);

this.params = params;
this.id = Math.random().toString().substr(2, 8);
this.id = Math.random().toString().substring(2, 10);

this.connect();
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/common/views/components/connect-failed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="mk-connect-failed">
<h1>{{ $t('title') }}</h1>
<p class="text">
<span>{{ this.$t('description').substr(0, this.$t('description').indexOf('{')) }}</span>
<span>{{ this.$t('description').substring(0, this.$t('description').indexOf('{')) }}</span>
<a @click="reload">{{ this.$t('description').match(/\{(.+?)\}/)[1] }}</a>
<span>{{ this.$t('description').substr(this.$t('description').indexOf('}') + 1) }}</span>
<span>{{ this.$t('description').substring(this.$t('description').indexOf('}') + 1) }}</span>
</p>
<button v-if="!troubleshooting" @click="troubleshooting = true">{{ $t('troubleshoot') }}</button>
<x-troubleshooter v-if="troubleshooting"/>
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/views/components/frac.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default Vue.extend({
length(value: number) {
const string = value.toString();
return string.includes('e') ? -~string.substr(string.indexOf('e')) : string.length;
return string.includes('e') ? -~string.substring(string.indexOf('e')) : string.length;
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/views/components/reaction-icon.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<mk-emoji :emoji="str.startsWith(':') ? null : str" :name="str.startsWith(':') ? str.substr(1, str.length - 2) : null" :is-reaction="true" :custom-emojis="customEmojis" :normal="true"/>
<mk-emoji :emoji="str.startsWith(':') ? null : str" :name="str.startsWith(':') ? str.substring(1, str.length - 1) : null" :is-reaction="true" :custom-emojis="customEmojis" :normal="true"/>
</template>

<script lang="ts">
Expand Down
14 changes: 7 additions & 7 deletions src/client/app/common/views/components/url.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<component :is="hasRoute ? 'router-link' : 'a'" class="mk-url" :[attr]="hasRoute ? url.substr(local.length) : url" :rel="rel" :target="target">
<component :is="hasRoute ? 'router-link' : 'a'" class="mk-url" :[attr]="hasRoute ? url.substring(local.length) : url" :rel="rel" :target="target">
<template v-if="!self">
<span class="schema">{{ schema }}//</span>
<span class="hostname">{{ hostname }}</span>
Expand All @@ -8,7 +8,7 @@
<template v-if="pathname === '/' && self">
<span class="self">{{ hostname }}</span>
</template>
<span class="pathname" v-if="pathname != ''">{{ self ? pathname.substr(1) : pathname }}</span>
<span class="pathname" v-if="pathname != ''">{{ self ? pathname.substring(1) : pathname }}</span>
<span class="query">{{ query }}</span>
<span class="hash">{{ hash }}</span>
<fa icon="external-link-square-alt" v-if="target === '_blank'"/>
Expand All @@ -25,11 +25,11 @@ export default Vue.extend({
data() {
const isSelf = this.url.startsWith(local);
const hasRoute = isSelf && (
(this.url.substr(local.length) === '/') ||
this.url.substr(local.length).startsWith('/@') ||
this.url.substr(local.length).startsWith('/notes/') ||
this.url.substr(local.length).startsWith('/tags/') ||
this.url.substr(local.length).startsWith('/pages/'));
(this.url.substring(local.length) === '/') ||
this.url.substring(local.length).startsWith('/@') ||
this.url.substring(local.length).startsWith('/notes/') ||
this.url.substring(local.length).startsWith('/tags/') ||
this.url.substring(local.length).startsWith('/pages/'));
return {
local,
schema: null,
Expand Down
20 changes: 10 additions & 10 deletions src/client/app/common/views/directives/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ 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('#');
Expand All @@ -95,23 +95,23 @@ 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;
}
}

if (isHashtag && !opened) {
const hashtag = text.substr(hashtagIndex + 1);
const hashtag = text.substring(hashtagIndex + 1);
if (!hashtag.includes(' ')) {
this.open('hashtag', hashtag);
opened = true;
}
}

if (isEmoji && !opened) {
const emoji = text.substr(emojiIndex + 1);
const emoji = text.substring(emojiIndex + 1);
if (emoji && !emoji.includes(' ')) {
this.open('emoji', emoji);
opened = true;
Expand Down Expand Up @@ -196,9 +196,9 @@ 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)}`;

Expand All @@ -214,9 +214,9 @@ 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}`;
Expand All @@ -230,9 +230,9 @@ 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;
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/common/views/widgets/posts-monitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default define({
this.connection.on('stats', this.onStats);
this.connection.on('statsLog', this.onStatsLog);
this.connection.send('requestLog',{
id: Math.random().toString().substr(2, 8)
id: Math.random().toString().substring(2, 10)
});
},
beforeDestroy() {
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/desktop/views/components/drive.file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<x-file-thumbnail class="thumbnail" :file="file" fit="contain"/>

<p class="name">
<span>{{ file.name.lastIndexOf('.') != -1 ? file.name.substr(0, file.name.lastIndexOf('.')) : file.name }}</span>
<span class="ext" v-if="file.name.lastIndexOf('.') != -1">{{ file.name.substr(file.name.lastIndexOf('.')) }}</span>
<span>{{ file.name.lastIndexOf('.') != -1 ? file.name.substring(0, file.name.lastIndexOf('.')) : file.name }}</span>
<span class="ext" v-if="file.name.lastIndexOf('.') != -1">{{ file.name.substring(file.name.lastIndexOf('.')) }}</span>
</p>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/desktop/views/components/ui.sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default Vue.extend({
if (q.startsWith('@')) {
this.$router.push(`/${q}`);
} else if (q.startsWith('#')) {
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
this.$router.push(`/tags/${encodeURIComponent(q.substring(1))}`);
} else if (q.startsWith('https://')) {
this.searching = true;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/desktop/views/components/user-preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default Vue.extend({
});
} else {
const query = this.user.startsWith('@') ?
parseAcct(this.user.substr(1)) :
parseAcct(this.user.substring(1)) :
{ userId: this.user };
this.$root.api('users/show', query).then(user => {
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/mobile/views/components/drive.file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<x-file-thumbnail class="thumbnail" :file="file" fit="cover"/>
<div class="body">
<p class="name">
<span>{{ file.name.lastIndexOf('.') != -1 ? file.name.substr(0, file.name.lastIndexOf('.')) : file.name }}</span>
<span class="ext" v-if="file.name.lastIndexOf('.') != -1">{{ file.name.substr(file.name.lastIndexOf('.')) }}</span>
<span>{{ file.name.lastIndexOf('.') != -1 ? file.name.substring(0, file.name.lastIndexOf('.')) : file.name }}</span>
<span class="ext" v-if="file.name.lastIndexOf('.') != -1">{{ file.name.substring(file.name.lastIndexOf('.')) }}</span>
</p>
<footer>
<span class="type"><mk-file-type-icon :type="file.type"/>{{ file.type }}</span>
Expand Down
6 changes: 3 additions & 3 deletions src/client/app/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ function compile(theme: Theme): { [key: string]: string } {
function getColor(code: string): tinycolor.Instance {
// ref
if (code[0] == '@') {
return getColor(theme.props[code.substr(1)]);
return getColor(theme.props[code.substring(1)]);
}
if (code[0] == '$') {
return getColor(theme.vars[code.substr(1)]);
return getColor(theme.vars[code.substring(1)]);
}

// func
if (code[0] == ':') {
const parts = code.split('<');
const func = parts.shift().substr(1);
const func = parts.shift().substring(1);
const arg = parseFloat(parts.shift());
const color = getColor(parts.join('<'));

Expand Down
Loading

0 comments on commit eb40267

Please sign in to comment.