2023-01-13 05:40:33 +01:00
|
|
|
import { url as instanceUrl } from "@/config";
|
|
|
|
import * as url from "@/scripts/url";
|
2019-02-04 19:51:54 +01:00
|
|
|
|
2019-02-13 15:45:35 +01:00
|
|
|
export function getStaticImageUrl(baseUrl: string): string {
|
|
|
|
const u = new URL(baseUrl);
|
2021-05-27 15:40:48 +02:00
|
|
|
if (u.href.startsWith(`${instanceUrl}/proxy/`)) {
|
|
|
|
// もう既にproxyっぽそうだったらsearchParams付けるだけ
|
2023-01-13 05:40:33 +01:00
|
|
|
u.searchParams.set("static", "1");
|
2021-05-27 15:40:48 +02:00
|
|
|
return u.href;
|
|
|
|
}
|
2023-01-13 05:40:33 +01:00
|
|
|
const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので
|
2019-02-13 15:45:35 +01:00
|
|
|
return `${instanceUrl}/proxy/${dummy}?${url.query({
|
|
|
|
url: u.href,
|
2023-01-13 05:40:33 +01:00
|
|
|
static: "1",
|
2019-02-13 15:45:35 +01:00
|
|
|
})}`;
|
2019-02-04 19:51:54 +01:00
|
|
|
}
|