diff options
| author | okayurisotto <okayurisotto@proton.me> | 2023-07-14 07:59:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-14 07:59:54 +0900 |
| commit | c0dbc3b53fc9056e444f10dbc2d4e71d2d4fa439 (patch) | |
| tree | 0038b0132ca8d6b561e518606c8e8d167b724f63 /packages/frontend/src/scripts/autocomplete.ts | |
| parent | fix runtime error (diff) | |
| download | sharkey-c0dbc3b53fc9056e444f10dbc2d4e71d2d4fa439.tar.gz sharkey-c0dbc3b53fc9056e444f10dbc2d4e71d2d4fa439.tar.bz2 sharkey-c0dbc3b53fc9056e444f10dbc2d4e71d2d4fa439.zip | |
refactor: `substr` -> `substring` (#11273)
Diffstat (limited to 'packages/frontend/src/scripts/autocomplete.ts')
| -rw-r--r-- | packages/frontend/src/scripts/autocomplete.ts | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/packages/frontend/src/scripts/autocomplete.ts b/packages/frontend/src/scripts/autocomplete.ts index 1bae3790f5..564573ae8a 100644 --- a/packages/frontend/src/scripts/autocomplete.ts +++ b/packages/frontend/src/scripts/autocomplete.ts @@ -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}`; |