Skip to content

Commit

Permalink
Revert "refactor(asset-proxy): encode url request to external source"
Browse files Browse the repository at this point in the history
This reverts commit ffb79ba.
  • Loading branch information
hugotiburtino committed Oct 30, 2024
1 parent ffb79ba commit 0816766
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __tests__/asset-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
9 changes: 3 additions & 6 deletions src/asset-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ export async function assetProxy(request: Request): Promise<Response | null> {
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)
Expand Down

0 comments on commit 0816766

Please sign in to comment.