Skip to content

Commit

Permalink
refactor(asset-proxy): build url first using Url class
Browse files Browse the repository at this point in the history
  • Loading branch information
hugotiburtino committed Oct 30, 2024
1 parent c79ba71 commit 59888d7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/asset-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export async function assetProxy(
if (url.subdomain !== 'asset-proxy') return null
if (url.pathname !== '/src') return null

const assetUrl = url.searchParams.get('url')
const urlParam = url.searchParams.get('url')

if (!assetUrl) throw new Error('Missing url for the asset')
if (!urlParam) throw new Error('Missing url for the asset')

const response = await fetch(assetUrl, { cf: { cacheTtl: 24 * 60 * 60 } })
const assetUrl = new Url(urlParam)

// Maybe add other validations?
if (response.ok) {
Expand Down

0 comments on commit 59888d7

Please sign in to comment.