Add prelude function for URL Query (#4135)

* Update string.ts

* Refactor

* Update string.ts

* Update wrap-url.ts

* Update string.ts

* Update get-static-image-url.ts

* Use querystring.stringify

* Update outbox.ts

* Back to the urlQuery

* Update followers.ts

* Update following.ts

* Update outbox.ts

* Update string.ts

* Update get-static-image-url.ts

* Update string.ts

* Update string.ts

* Separate prelude files
This commit is contained in:
Acid Chicken (硫酸鶏)
2019-02-13 23:45:35 +09:00
committed by GitHub
parent 3548290ff2
commit 4b6c113251
5 changed files with 48 additions and 14 deletions

View File

@ -1,9 +1,11 @@
import { url as instanceUrl } from '../../config';
import * as url from '../../../../prelude/url';
export function getStaticImageUrl(url: string): string {
const u = new URL(url);
export function getStaticImageUrl(baseUrl: string): string {
const u = new URL(baseUrl);
const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので
let result = `${instanceUrl}/proxy/${dummy}?url=${encodeURIComponent(u.href)}`;
result += '&static=1';
return result;
return `${instanceUrl}/proxy/${dummy}?${url.query({
url: u.href,
static: '1'
})}`;
}