summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-08-25 22:42:26 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2018-08-25 22:42:26 +0900
commit08a59591ae25280cf11e49d0f5eab4d5a438e147 (patch)
tree58086582b6319664ed9571f45593d637e3f1a672 /src
parentMerge branch 'develop' of https://github.com/syuilo/misskey into develop (diff)
downloadsharkey-08a59591ae25280cf11e49d0f5eab4d5a438e147.tar.gz
sharkey-08a59591ae25280cf11e49d0f5eab4d5a438e147.tar.bz2
sharkey-08a59591ae25280cf11e49d0f5eab4d5a438e147.zip
Use startsWith and endsWith for readability
Diffstat (limited to 'src')
-rw-r--r--src/client/app/desktop/views/components/user-preview.vue2
-rw-r--r--src/mfm/parse/core/syntax-highlighter.ts2
-rw-r--r--src/mfm/parse/elements/hashtag.ts2
-rw-r--r--src/mfm/parse/elements/link.ts2
-rw-r--r--src/misc/fa.ts4
-rw-r--r--src/server/api/common/is-native-token.ts2
6 files changed, 7 insertions, 7 deletions
diff --git a/src/client/app/desktop/views/components/user-preview.vue b/src/client/app/desktop/views/components/user-preview.vue
index 7ef8dff5be..1e1755ec3c 100644
--- a/src/client/app/desktop/views/components/user-preview.vue
+++ b/src/client/app/desktop/views/components/user-preview.vue
@@ -48,7 +48,7 @@ export default Vue.extend({
this.open();
});
} else {
- const query = this.user[0] == '@' ?
+ const query = this.user.startsWith('@') ?
parseAcct(this.user.substr(1)) :
{ userId: this.user };
diff --git a/src/mfm/parse/core/syntax-highlighter.ts b/src/mfm/parse/core/syntax-highlighter.ts
index 3fb7a3b73d..2b13608d2b 100644
--- a/src/mfm/parse/core/syntax-highlighter.ts
+++ b/src/mfm/parse/core/syntax-highlighter.ts
@@ -197,7 +197,7 @@ const elements: Element[] = [
if (thisIsNotARegexp) return null;
if (regexp == '') return null;
- if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null;
+ if (regexp.startsWith(' ') && regexp.endsWith(' ')) return null;
return {
html: `<span class="regexp">/${escape(regexp)}/</span>`,
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];
diff --git a/src/misc/fa.ts b/src/misc/fa.ts
index 077bb51e6d..8be06362c3 100644
--- a/src/misc/fa.ts
+++ b/src/misc/fa.ts
@@ -25,9 +25,9 @@ export const replacement = (match: string, key: string) => {
arg == 'S' ? 'fas' :
arg == 'B' ? 'fab' :
'';
- } else if (arg[0] == '.') {
+ } else if (arg.startsWith('.')) {
classes.push('fa-' + arg.substr(1));
- } else if (arg[0] == '-') {
+ } else if (arg.startsWith('-')) {
transform = arg.substr(1).split('|').join(' ');
} else {
name = arg;
diff --git a/src/server/api/common/is-native-token.ts b/src/server/api/common/is-native-token.ts
index 0769a4812e..6afbc99ab5 100644
--- a/src/server/api/common/is-native-token.ts
+++ b/src/server/api/common/is-native-token.ts
@@ -1 +1 @@
-export default (token: string) => token[0] == '!';
+export default (token: string) => token.startsWith('!');