diff --git a/src/client/components/link.vue b/src/client/components/link.vue index 0775140c4e..f4e07c1627 100644 --- a/src/client/components/link.vue +++ b/src/client/components/link.vue @@ -1,5 +1,5 @@ <template> -<component :is="hasRoute ? 'router-link' : 'a'" class="xlcxczvw _link" :[attr]="hasRoute ? url.substr(local.length) : url" :rel="rel" :target="target" +<component :is="self ? 'router-link' : 'a'" class="xlcxczvw _link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target" @mouseover="onMouseover" @mouseleave="onMouseleave" :title="url" @@ -27,18 +27,12 @@ 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/')); + const self = this.url.startsWith(local); return { local, - self: isSelf, - hasRoute: hasRoute, - attr: hasRoute ? 'to' : 'href', - target: hasRoute ? null : '_blank', + self: self, + attr: self ? 'to' : 'href', + target: self ? null : '_blank', showTimer: null, hideTimer: null, preview: null, diff --git a/src/client/components/url-preview.vue b/src/client/components/url-preview.vue index f2ef1f1ba3..940d3892db 100644 --- a/src/client/components/url-preview.vue +++ b/src/client/components/url-preview.vue @@ -10,7 +10,7 @@ </div> <div v-else class="mk-url-preview" v-size="[{ max: 400 }, { max: 350 }]"> <transition name="zoom" mode="out-in"> - <component :is="hasRoute ? 'router-link' : 'a'" :class="{ compact }" :[attr]="hasRoute ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url" v-if="!fetching"> + <component :is="self ? 'router-link' : 'a'" :class="{ compact }" :[attr]="self ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url" v-if="!fetching"> <div class="thumbnail" v-if="thumbnail" :style="`background-image: url('${thumbnail}')`"> <button class="_button" v-if="!playerEnabled && player.url" @click.prevent="playerEnabled = true" :title="$t('enable-player')"><fa :icon="faPlayCircle"/></button> </div> @@ -58,12 +58,7 @@ export default Vue.extend({ }, data() { - const isSelf = this.url.startsWith(local); - const hasRoute = - (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/'); + const self = this.url.startsWith(local); return { local, fetching: true, @@ -79,10 +74,9 @@ export default Vue.extend({ }, tweetUrl: null, playerEnabled: false, - self: isSelf, - hasRoute: hasRoute, - attr: hasRoute ? 'to' : 'href', - target: hasRoute ? null : '_blank', + self: self, + attr: self ? 'to' : 'href', + target: self ? null : '_blank', faPlayCircle }; }, diff --git a/src/client/components/url.vue b/src/client/components/url.vue index 23f2be7be3..d81c98deb5 100644 --- a/src/client/components/url.vue +++ b/src/client/components/url.vue @@ -1,5 +1,5 @@ <template> -<component :is="hasRoute ? 'router-link' : 'a'" class="ieqqeuvs _link" :[attr]="hasRoute ? url.substr(local.length) : url" :rel="rel" :target="target" +<component :is="self ? 'router-link' : 'a'" class="ieqqeuvs _link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target" @mouseover="onMouseover" @mouseleave="onMouseleave" > @@ -37,12 +37,7 @@ 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/')); + const self = this.url.startsWith(local); return { local, schema: null as string | null, @@ -51,10 +46,9 @@ export default Vue.extend({ pathname: null as string | null, query: null as string | null, hash: null as string | null, - self: isSelf, - hasRoute: hasRoute, - attr: hasRoute ? 'to' : 'href', - target: hasRoute ? null : '_blank', + self: self, + attr: self ? 'to' : 'href', + target: self ? null : '_blank', showTimer: null, hideTimer: null, preview: null,