From af649b04809e7feb6c50d37718a513756f888ae1 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 25 Dec 2022 18:05:53 +0900 Subject: [PATCH] encodeURIComponent for static image proxy filename (#9410) --- packages/client/src/scripts/get-static-image-url.ts | 5 ++++- packages/sw/src/scripts/create-notification.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/client/src/scripts/get-static-image-url.ts b/packages/client/src/scripts/get-static-image-url.ts index 79dbcf932..cbd176198 100644 --- a/packages/client/src/scripts/get-static-image-url.ts +++ b/packages/client/src/scripts/get-static-image-url.ts @@ -8,7 +8,10 @@ export function getStaticImageUrl(baseUrl: string): string { u.searchParams.set('static', '1'); return u.href; } - const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので + + // 拡張子がないとキャッシュしてくれないCDNがあるのでダミーの名前を指定する + const dummy = `${encodeURIComponent(`${u.host}${u.pathname}`)}.webp`; + return `${instanceUrl}/proxy/${dummy}?${url.query({ url: u.href, static: '1', diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts index fd5b0fa31..a324851fe 100644 --- a/packages/sw/src/scripts/create-notification.ts +++ b/packages/sw/src/scripts/create-notification.ts @@ -137,7 +137,8 @@ async function composeNotification(data u.searchParams.set('badge', '1'); badge = u.href; } else { - const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので + // 拡張子がないとキャッシュしてくれないCDNがあるので + const dummy = `${encodeURIComponent(`${u.host}${u.pathname}`)}.png`; badge = `${origin}/proxy/${dummy}?${url.query({ url: u.href, badge: '1'