summaryrefslogtreecommitdiff
path: root/src/mfm/parse/elements
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-08-26 01:18:34 +0900
committerGitHub <noreply@github.com>2018-08-26 01:18:34 +0900
commita1fca2550ec7ff76e955c8e81bd1e785b0f61beb (patch)
tree58086582b6319664ed9571f45593d637e3f1a672 /src/mfm/parse/elements
parentMerge branch 'develop' of https://github.com/syuilo/misskey into develop (diff)
parentUse startsWith and endsWith for readability (diff)
downloadmisskey-a1fca2550ec7ff76e955c8e81bd1e785b0f61beb.tar.gz
misskey-a1fca2550ec7ff76e955c8e81bd1e785b0f61beb.tar.bz2
misskey-a1fca2550ec7ff76e955c8e81bd1e785b0f61beb.zip
Merge pull request #2488 from syuilo/refactor-string
Use startsWith and endsWith for readability
Diffstat (limited to 'src/mfm/parse/elements')
-rw-r--r--src/mfm/parse/elements/hashtag.ts2
-rw-r--r--src/mfm/parse/elements/link.ts2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/mfm/parse/elements/hashtag.ts b/src/mfm/parse/elements/hashtag.ts
index 129041774f..f4b6a78fa8 100644
--- a/src/mfm/parse/elements/hashtag.ts
+++ b/src/mfm/parse/elements/hashtag.ts
@@ -10,7 +10,7 @@ export type TextElementHashtag = {
export default function(text: string, i: number) {
if (!(/^\s#[^\s]+/.test(text) || (i == 0 && /^#[^\s]+/.test(text)))) return null;
- const isHead = text[0] == '#';
+ const isHead = text.startsWith('#');
const hashtag = text.match(/^\s?#[^\s]+/)[0];
const res: any[] = !isHead ? [{
type: 'text',
diff --git a/src/mfm/parse/elements/link.ts b/src/mfm/parse/elements/link.ts
index b353aebc5c..796aeb1ab3 100644
--- a/src/mfm/parse/elements/link.ts
+++ b/src/mfm/parse/elements/link.ts
@@ -13,7 +13,7 @@ export type TextElementLink = {
export default function(text: string) {
const match = text.match(/^\??\[([^\[\]]+?)\]\((https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+?)\)/);
if (!match) return null;
- const silent = text[0] == '?';
+ const silent = text.startsWith('?');
const link = match[0];
const title = match[1];
const url = match[2];