summaryrefslogtreecommitdiff
path: root/src/client/components/url-preview.vue
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-02-10 20:51:17 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-02-10 20:51:17 +0900
commit9cf42d8b33a4105afca20d34b291fddf4c98fece (patch)
tree4f8809b01ed54599f00f49e34e011d5eb01df902 /src/client/components/url-preview.vue
parent:art: (diff)
downloadmisskey-9cf42d8b33a4105afca20d34b291fddf4c98fece.tar.gz
misskey-9cf42d8b33a4105afca20d34b291fddf4c98fece.tar.bz2
misskey-9cf42d8b33a4105afca20d34b291fddf4c98fece.zip
Better self link detection
Diffstat (limited to 'src/client/components/url-preview.vue')
-rw-r--r--src/client/components/url-preview.vue16
1 files changed, 5 insertions, 11 deletions
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
};
},