Skip to content

Commit

Permalink
fix: encode url param in image optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Aug 2, 2021
1 parent 6378af8 commit 1de8b19
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/next/server/image-optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,22 @@ export async function imageOptimizer(
}

const { headers } = req
const { url, w, q } = parsedUrl.query
const { url: decodedUrl, w, q } = parsedUrl.query
const mimeType = getSupportedMimeType(MODERN_TYPES, headers.accept)
let href: string

if (!url) {
if (!decodedUrl) {
res.statusCode = 400
res.end('"url" parameter is required')
return { finished: true }
} else if (Array.isArray(url)) {
} else if (Array.isArray(decodedUrl)) {
res.statusCode = 400
res.end('"url" parameter cannot be an array')
return { finished: true }
}

const url = encodeURI(decodedUrl)

let isAbsolute: boolean

if (url.startsWith('/')) {
Expand Down

0 comments on commit 1de8b19

Please sign in to comment.