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