summaryrefslogtreecommitdiff
path: root/packages/frontend/src/utility
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-03-02 16:05:12 -0500
committerFreya Murphy <freya@freyacat.org>2026-03-02 18:39:22 -0500
commit24734d408700a72d45c3ff4a679606cab3ec544f (patch)
treed0fee0bcf508f3c631f7c26724bb5cd94dfc88a0 /packages/frontend/src/utility
parentmerge: Release/2025.4.5 (!1258) (diff)
downloadsharkey-24734d408700a72d45c3ff4a679606cab3ec544f.tar.gz
sharkey-24734d408700a72d45c3ff4a679606cab3ec544f.tar.bz2
sharkey-24734d408700a72d45c3ff4a679606cab3ec544f.zip
split url into webUrl and localUrl (like mastodon)stable
Diffstat (limited to 'packages/frontend/src/utility')
-rw-r--r--packages/frontend/src/utility/get-embed-code.ts6
-rw-r--r--packages/frontend/src/utility/get-note-menu.ts8
-rw-r--r--packages/frontend/src/utility/get-user-menu.ts8
-rw-r--r--packages/frontend/src/utility/getNoteUrls.ts8
-rw-r--r--packages/frontend/src/utility/media-proxy.ts8
-rw-r--r--packages/frontend/src/utility/player-url-transform.ts4
-rw-r--r--packages/frontend/src/utility/popout.ts2
7 files changed, 22 insertions, 22 deletions
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 = [
- `<iframe src="${url + path + paramString}" data-misskey-embed-id="${iframeId}" loading="lazy" referrerpolicy="strict-origin-when-cross-origin" style="border: none; width: 100%; max-width: 500px; height: 300px; color-scheme: light dark;"></iframe>`,
- `<script defer src="${url}/embed.js"></script>`,
+ `<iframe src="${webUrl + path + paramString}" data-misskey-embed-id="${iframeId}" loading="lazy" referrerpolicy="strict-origin-when-cross-origin" style="border: none; width: 100%; max-width: 500px; height: 300px; color-scheme: light dark;"></iframe>`,
+ `<script defer src="${webUrl}/embed.js"></script>`,
];
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<MediaProxy['getProxiedImageUrl']>): 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<MediaProxy['getProxiedIma
export function getProxiedImageUrlNullable(...args: Parameters<MediaProxy['getProxiedImageUrlNullable']>): 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<MediaProxy['getPr
export function getStaticImageUrl(...args: Parameters<MediaProxy['getStaticImageUrl']>): 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();