Skip to content

Commit

Permalink
Merge pull request #2373 from graphcommerce-org/feature/redirect-lega…
Browse files Browse the repository at this point in the history
…cy-html-suffix

Handle the case where one switches from using the default .html URL suffix, to not using one
  • Loading branch information
paales authored Sep 19, 2024
2 parents a973f21 + 53ffc91 commit e941ee4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-lies-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-store': minor
---

Handle the case where one switches from using the default .html URL suffix, to not using one
5 changes: 5 additions & 0 deletions packages/magento-store/utils/redirectOrNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export async function redirectOrNotFound(
candidates.add(from.endsWith(suffix) ? from.slice(0, -suffix.length) : `${from}${suffix}`)
})

// Handle the case where we transition from using the default .html suffix, to not using one
if (from.endsWith('.html')) {
candidates.add(from.slice(0, -('.html'.length)))
}

const routePromises = [...candidates].filter(Boolean).map(
async (url) =>
(
Expand Down

0 comments on commit e941ee4

Please sign in to comment.