diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-06-21 15:41:02 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-06-21 15:41:02 +0900 |
| commit | 16b03fc157507261c54e5bb0eb030dcf6418a68c (patch) | |
| tree | cda129a6a562bf156a6bfbed82a98bccaacff49a /src/client/app/common/views | |
| parent | Fix bug (diff) | |
| download | misskey-16b03fc157507261c54e5bb0eb030dcf6418a68c.tar.gz misskey-16b03fc157507261c54e5bb0eb030dcf6418a68c.tar.bz2 misskey-16b03fc157507261c54e5bb0eb030dcf6418a68c.zip | |
Improve url-preview (#5077)
* url-previewリクエスト時にハッシュは除く
* ハッシュだけ違うプレビューカードは表示しない
* url-previewをユーザーロケールで出し分けるように
* Fix code style
Diffstat (limited to 'src/client/app/common/views')
| -rw-r--r-- | src/client/app/common/views/components/url-preview.vue | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/client/app/common/views/components/url-preview.vue b/src/client/app/common/views/components/url-preview.vue index 9c61e46059..20fbcbb046 100644 --- a/src/client/app/common/views/components/url-preview.vue +++ b/src/client/app/common/views/components/url-preview.vue @@ -30,7 +30,7 @@ <script lang="ts"> import Vue from 'vue'; import i18n from '../../../i18n'; -import { url as local } from '../../../config'; +import { url as local, lang } from '../../../config'; export default Vue.extend({ i18n: i18n('common/views/components/url-preview.vue'), @@ -89,10 +89,10 @@ export default Vue.extend({ }, created() { - const url = new URL(this.url); + const requestUrl = new URL(this.url); - if (this.detail && url.hostname == 'twitter.com' && /^\/.+\/status(es)?\/\d+/.test(url.pathname)) { - this.tweetUrl = url; + if (this.detail && requestUrl.hostname == 'twitter.com' && /^\/.+\/status(es)?\/\d+/.test(requestUrl.pathname)) { + this.tweetUrl = requestUrl; const twttr = (window as any).twttr || {}; const loadTweet = () => twttr.widgets.load(this.$refs.tweet); @@ -113,10 +113,15 @@ export default Vue.extend({ return; } - if (url.hostname === 'music.youtube.com') - url.hostname = 'youtube.com'; + if (requestUrl.hostname === 'music.youtube.com') { + requestUrl.hostname = 'youtube.com'; + } + + const requestLang = (lang || 'ja-JP').replace('ja-KS', 'ja-JP'); + + requestUrl.hash = ''; - fetch(`/url?url=${encodeURIComponent(this.url)}`).then(res => { + fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${requestLang}`).then(res => { res.json().then(info => { if (info.url == null) return; this.title = info.title; |