From 08167665f6ac6775f21f98fe6c037843e6f5a90b Mon Sep 17 00:00:00 2001 From: Hugo Tiburtino <45924645+hugotiburtino@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:56:21 +0100 Subject: [PATCH] Revert "refactor(asset-proxy): encode url request to external source" This reverts commit ffb79ba10c92c77ec5fcbf4728a9dc841391104d. --- __tests__/asset-proxy.ts | 2 +- src/asset-proxy.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/__tests__/asset-proxy.ts b/__tests__/asset-proxy.ts index 64b60c1a..71888d35 100644 --- a/__tests__/asset-proxy.ts +++ b/__tests__/asset-proxy.ts @@ -28,7 +28,7 @@ test('request to https://asset-proxy.serlo.org/src?url=* gets asset from url que const env = currentTestEnvironment() const response = await env.fetch({ subdomain: 'asset-proxy', - pathname: `/src?url=${encodeURIComponent('https://whatever.org/image')}`, + pathname: '/src?url=https://whatever.org/image', }) expect(response.status).toBe(200) expect(response.headers.get('content-type')).toBe('image/png') diff --git a/src/asset-proxy.ts b/src/asset-proxy.ts index 400b4353..a712e7ba 100644 --- a/src/asset-proxy.ts +++ b/src/asset-proxy.ts @@ -18,12 +18,9 @@ export async function assetProxy(request: Request): Promise { return getPlaceholder() } - const originalResponse = await fetch( - encodeURIComponent(assetUrl.toString()), - { - cf: { cacheTtl: 24 * 60 * 60 }, - }, - ) + const originalResponse = await fetch(assetUrl, { + cf: { cacheTtl: 24 * 60 * 60 }, + }) if (originalResponse.ok && isImageResponse(originalResponse)) { const response = new Response(originalResponse.body, originalResponse)