refactor: Extract well-known services

This commit is contained in:
syuilo
2020-08-07 11:27:37 +09:00
parent 2bdcd22ad4
commit 2d40a15d2b
3 changed files with 18 additions and 18 deletions

View File

@ -18,6 +18,7 @@
import Vue from 'vue';
import { toUnicode } from 'punycode';
import { host as localHost } from '../config';
import { wellKnownServices } from '../../well-known-services';
export default Vue.extend({
props: {
@ -37,12 +38,11 @@ export default Vue.extend({
},
computed: {
url(): string {
switch (this.host) {
case 'twitter.com':
case 'github.com':
return `https://${this.host}/${this.username}`;
default:
return `/${this.canonical}`;
const wellKnown = wellKnownServices.find(x => x[0] === this.host);
if (wellKnown) {
return wellKnown[1](this.username);
} else {
return `/${this.canonical}`;
}
},
canonical(): string {