Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Mar 22, 2024
1 parent 4ca7214 commit 7089341
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkUrlWarningDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ onBeforeUnmount(() => {
}
.urlAddress {
padding: 8px;
padding: var(--margin);
border-radius: calc(var(--radius) / 2);
border: 1px solid var(--divider);
overflow-x: auto;
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/src/scripts/warning-external-website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@

import { url as local } from '@/config.js';
import { instance } from '@/instance.js';
import { defaultStore } from '@/store.js';
import * as os from '@/os.js';
import MkUrlWarningDialog from '@/components/MkUrlWarningDialog.vue';

const isRegExp = /^\/(.+)\/(.*)$/;

export async function warningExternalWebsite(ev: MouseEvent, url: string) {
const _url = new URL(url);

const self = url.startsWith(local);
const isWellKnownWebsite = self || instance.wellKnownWebsites.some(expression => {
const r = isRegExp.exec(expression);
if (r) {
return new RegExp(r[1], r[2]).test(url);
} else return expression.split(' ').every(keyword => url.includes(keyword));
});
const isTrustedByUser = defaultStore.reactiveState.trustedDomains.value.includes(_url.hostname);

if (!self && !isWellKnownWebsite) {
if (!self && !isWellKnownWebsite && !isTrustedByUser) {
ev.preventDefault();
ev.stopPropagation();

Expand Down

0 comments on commit 7089341

Please sign in to comment.