From 24734d408700a72d45c3ff4a679606cab3ec544f Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 2 Mar 2026 16:05:12 -0500 Subject: split url into webUrl and localUrl (like mastodon) --- packages/frontend/src/utility/get-embed-code.ts | 6 +++--- packages/frontend/src/utility/get-note-menu.ts | 8 ++++---- packages/frontend/src/utility/get-user-menu.ts | 8 ++++---- packages/frontend/src/utility/getNoteUrls.ts | 8 ++++---- packages/frontend/src/utility/media-proxy.ts | 8 ++++---- packages/frontend/src/utility/player-url-transform.ts | 4 ++-- packages/frontend/src/utility/popout.ts | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) (limited to 'packages/frontend/src/utility') diff --git a/packages/frontend/src/utility/get-embed-code.ts b/packages/frontend/src/utility/get-embed-code.ts index d458e64f19..c4741d73f5 100644 --- a/packages/frontend/src/utility/get-embed-code.ts +++ b/packages/frontend/src/utility/get-embed-code.ts @@ -4,7 +4,7 @@ */ import { defineAsyncComponent } from 'vue'; import { v4 as uuid } from 'uuid'; -import { url } from '@@/js/config.js'; +import { webUrl } from '@@/js/config.js'; import { defaultEmbedParams, embedRouteWithScrollbar } from '@@/js/embed-page.js'; import type { EmbedParams, EmbeddableEntity } from '@@/js/embed-page.js'; import * as os from '@/os.js'; @@ -53,8 +53,8 @@ export function getEmbedCode(path: string, params?: EmbedParams): string { } const iframeCode = [ - ``, - ``, + ``, + ``, ]; return iframeCode.join('\n'); } diff --git a/packages/frontend/src/utility/get-note-menu.ts b/packages/frontend/src/utility/get-note-menu.ts index 056480a7ef..0096ed68da 100644 --- a/packages/frontend/src/utility/get-note-menu.ts +++ b/packages/frontend/src/utility/get-note-menu.ts @@ -5,7 +5,7 @@ import { defineAsyncComponent } from 'vue'; import * as Misskey from 'misskey-js'; -import { url } from '@@/js/config.js'; +import { webUrl } from '@@/js/config.js'; import { claimAchievement } from './achievements.js'; import type { Ref, ShallowRef } from 'vue'; import type { MenuItem } from '@/types/menu.js'; @@ -137,7 +137,7 @@ export function getAbuseNoteMenu(note: Misskey.entities.Note, text: string): Men icon: 'ti ti-exclamation-circle', text, action: (): void => { - const localUrl = `${url}/notes/${note.id}`; + const localUrl = `${webUrl}/notes/${note.id}`; let noteInfo = ''; if (note.url ?? note.uri != null) noteInfo = `Note: ${note.url ?? note.uri}\n`; noteInfo += `Local Note: ${localUrl}\n`; @@ -156,7 +156,7 @@ export function getCopyNoteLinkMenu(note: Misskey.entities.Note, text: string): icon: 'ti ti-link', text, action: (): void => { - copyToClipboard(`${url}/notes/${note.id}`); + copyToClipboard(`${webUrl}/notes/${note.id}`); }, }; } @@ -282,7 +282,7 @@ export function getNoteMenu(props: { navigator.share({ title: i18n.tsx.noteOf({ user: appearNote.user.name ?? appearNote.user.username }), text: appearNote.text ?? '', - url: `${url}/notes/${appearNote.id}`, + url: `${webUrl}/notes/${appearNote.id}`, }); } diff --git a/packages/frontend/src/utility/get-user-menu.ts b/packages/frontend/src/utility/get-user-menu.ts index fde390cece..e1a746b579 100644 --- a/packages/frontend/src/utility/get-user-menu.ts +++ b/packages/frontend/src/utility/get-user-menu.ts @@ -6,7 +6,7 @@ import { toUnicode } from 'punycode.js'; import { defineAsyncComponent, ref, watch } from 'vue'; import * as Misskey from 'misskey-js'; -import { host, url } from '@@/js/config.js'; +import { localHost, webUrl } from '@@/js/config.js'; import type { Router } from '@/router.js'; import type { MenuItem } from '@/types/menu.js'; import { i18n } from '@/i18n.js'; @@ -164,7 +164,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router icon: 'ti ti-at', text: i18n.ts.copyUsername, action: () => { - copyToClipboard(`@${user.username}@${user.host ?? host}`); + copyToClipboard(`@${user.username}@${user.host ?? localHost}`); }, }); @@ -173,7 +173,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router text: i18n.ts.copyProfileUrl, action: () => { const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`; - copyToClipboard(`${url}/${canonical}`); + copyToClipboard(`${webUrl}/${canonical}`); }, }); @@ -181,7 +181,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router icon: 'ti ti-rss', text: i18n.ts.copyRSS, action: () => { - copyToClipboard(`${user.host ?? host}/@${user.username}.atom`); + copyToClipboard(`${user.host ?? localHost}/@${user.username}.atom`); }, }); diff --git a/packages/frontend/src/utility/getNoteUrls.ts b/packages/frontend/src/utility/getNoteUrls.ts index efd014cbf0..c92e3a868b 100644 --- a/packages/frontend/src/utility/getNoteUrls.ts +++ b/packages/frontend/src/utility/getNoteUrls.ts @@ -9,7 +9,7 @@ import type * as Misskey from 'misskey-js'; export function getNoteUrls(note: Misskey.entities.Note): string[] { const urls: string[] = [ // Any note - `${config.url}/notes/${note.id}`, + `${config.webUrl}/notes/${note.id}`, ]; // Remote note @@ -18,7 +18,7 @@ export function getNoteUrls(note: Misskey.entities.Note): string[] { if (note.reply) { // Any Reply - urls.push(`${config.url}/notes/${note.reply.id}`); + urls.push(`${config.webUrl}/notes/${note.reply.id}`); // Remote Reply if (note.reply.url) urls.push(note.reply.url); if (note.reply.uri) urls.push(note.reply.uri); @@ -26,7 +26,7 @@ export function getNoteUrls(note: Misskey.entities.Note): string[] { if (note.renote) { // Any Renote - urls.push(`${config.url}/notes/${note.renote.id}`); + urls.push(`${config.webUrl}/notes/${note.renote.id}`); // Remote Renote if (note.renote.url) urls.push(note.renote.url); if (note.renote.uri) urls.push(note.renote.uri); @@ -34,7 +34,7 @@ export function getNoteUrls(note: Misskey.entities.Note): string[] { if (note.renote?.renote) { // Any Quote - urls.push(`${config.url}/notes/${note.renote.renote.id}`); + urls.push(`${config.webUrl}/notes/${note.renote.renote.id}`); // Remote Quote if (note.renote.renote.url) urls.push(note.renote.renote.url); if (note.renote.renote.uri) urls.push(note.renote.renote.uri); diff --git a/packages/frontend/src/utility/media-proxy.ts b/packages/frontend/src/utility/media-proxy.ts index 78eba35ead..d93c0448d1 100644 --- a/packages/frontend/src/utility/media-proxy.ts +++ b/packages/frontend/src/utility/media-proxy.ts @@ -4,14 +4,14 @@ */ import { MediaProxy } from '@@/js/media-proxy.js'; -import { url } from '@@/js/config.js'; +import { webUrl } from '@@/js/config.js'; import { instance } from '@/instance.js'; let _mediaProxy: MediaProxy | null = null; export function getProxiedImageUrl(...args: Parameters): string { if (_mediaProxy == null) { - _mediaProxy = new MediaProxy(instance, url); + _mediaProxy = new MediaProxy(instance, webUrl); } return _mediaProxy.getProxiedImageUrl(...args); @@ -19,7 +19,7 @@ export function getProxiedImageUrl(...args: Parameters): string | null { if (_mediaProxy == null) { - _mediaProxy = new MediaProxy(instance, url); + _mediaProxy = new MediaProxy(instance, webUrl); } return _mediaProxy.getProxiedImageUrlNullable(...args); @@ -27,7 +27,7 @@ export function getProxiedImageUrlNullable(...args: Parameters): string { if (_mediaProxy == null) { - _mediaProxy = new MediaProxy(instance, url); + _mediaProxy = new MediaProxy(instance, webUrl); } return _mediaProxy.getStaticImageUrl(...args); diff --git a/packages/frontend/src/utility/player-url-transform.ts b/packages/frontend/src/utility/player-url-transform.ts index 39c6df6500..068a11874e 100644 --- a/packages/frontend/src/utility/player-url-transform.ts +++ b/packages/frontend/src/utility/player-url-transform.ts @@ -2,7 +2,7 @@ * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ -import { hostname } from '@@/js/config.js'; +import { webHost } from '@@/js/config.js'; export function transformPlayerUrl(url: string): string { const urlObj = new URL(url); @@ -13,7 +13,7 @@ export function transformPlayerUrl(url: string): string { if (urlObj.hostname === 'player.twitch.tv') { // TwitchはCSPの制約あり // https://dev.twitch.tv/docs/embed/video-and-clips/ - urlParams.set('parent', hostname); + urlParams.set('parent', webHost); urlParams.set('allowfullscreen', ''); urlParams.set('autoplay', 'true'); } else { diff --git a/packages/frontend/src/utility/popout.ts b/packages/frontend/src/utility/popout.ts index 5b141222e8..6cde3d8a33 100644 --- a/packages/frontend/src/utility/popout.ts +++ b/packages/frontend/src/utility/popout.ts @@ -7,7 +7,7 @@ import { appendQuery } from '@@/js/url.js'; import * as config from '@@/js/config.js'; export function popout(path: string, w?: HTMLElement) { - let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.url + path; + let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.webUrl + path; url = appendQuery(url, 'zen'); if (w) { const position = w.getBoundingClientRect(); -- cgit v1.2.3-freya