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