Skip to content

Commit

Permalink
don't use path prefix for alternate image cdn url
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Nov 13, 2023
1 parent 36b918a commit 5b81ecd
Showing 1 changed file with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function generateImageUrl(
store?: Store
): string {
if (process.env.NETLIFY_IMAGE_CDN) {
return generateImageUrlAlt(source, imageArgs, store)
return generateImageUrlAlt(source, imageArgs)
}
const filenameWithoutExt = basename(source.filename, extname(source.filename))
const queryStr = generateImageArgs(imageArgs)
Expand Down Expand Up @@ -183,13 +183,12 @@ export function generateImageUrlAlt(
mimeType: string
internal: { contentDigest: string }
},
imageArgs: Parameters<typeof generateImageArgs>[0],
store?: Store
imageArgs: Parameters<typeof generateImageArgs>[0]
): string {
const placeholderOrigin = `http://netlify.com`
const imageParams = generateImageArgsAlt(imageArgs)

const baseURL = new URL(`${placeholderOrigin}/${generateRoutePrefix(store)}`)
const baseURL = new URL(`${placeholderOrigin}/.netlify/images`)

baseURL.search = imageParams.toString()
baseURL.searchParams.append(`url`, source.url)
Expand All @@ -198,16 +197,6 @@ export function generateImageUrlAlt(
return `${baseURL.pathname}${baseURL.search}`
}

function generateRoutePrefix(store?: Store): string {
const state = store?.getState()

const pathPrefix = state?.program?.prefixPaths
? state?.config?.pathPrefix
: ``

return pathPrefix + `.netlify/images`
}

export function generateImageArgsAlt({
width,
height,
Expand Down

0 comments on commit 5b81ecd

Please sign in to comment.