Skip to content

Commit

Permalink
remove auto add ext
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jan 24, 2024
1 parent 5f50abe commit a20a9c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,16 @@ ${errorOnBadHandler(resourcePath)}
${'' /* re-export the userland route configs */}
export * from ${JSON.stringify(resourcePath)}
function appendXmlExtension(id) {
return id && !id.endsWith('.xml') ? id + '.xml' : id
}
export async function GET(_, ctx) {
const { __metadata_id__, ...params } = ctx.params || {}
${
'' /* sitemap will be optimized to [__metadata_id__] from [[..._metadata_id__]] in production */
}
let targetId = process.env.NODE_ENV !== 'production'
const targetId = process.env.NODE_ENV !== 'production'
? __metadata_id__?.[0]
: __metadata_id__
targetId = appendXmlExtension(targetId)
let id = undefined
const sitemaps = generateSitemaps ? await generateSitemaps() : null
Expand All @@ -212,8 +207,8 @@ export async function GET(_, ctx) {
throw new Error('id property is required for every item returned from generateSitemaps')
}
}
const currentId = appendXmlExtension(item.id.toString())
return currentId === targetId
return item.id.toString() === targetId
})?.id
if (id == null) {
return new NextResponse('Not Found', {
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/app-dir/metadata-dynamic-routes/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ createNextDescribe(
const ids = ['child0', 'child1', 'child2', 'child3']
function fetchSitemap(id) {
return next
.fetch(
isNextDev
? `/gsp/sitemap.xml/${id}.xml`
: `/gsp/sitemap/${id}.xml`
)
.fetch(isNextDev ? `/gsp/sitemap.xml/${id}` : `/gsp/sitemap/${id}`)
.then((res) => res.text())
}

Expand Down

0 comments on commit a20a9c5

Please sign in to comment.