Skip to content

Commit

Permalink
Merge pull request #5918 from kodadot/fix/redirect-rmrk2-to-ksm
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwao authored May 12, 2023
2 parents 665fd17 + 71774bf commit 7a14f72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions middleware/redirects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default function ({ store, redirect, route }): void {
const prefix = store.getters.currentUrlPrefix

if (route.path.startsWith(`/${prefix}`)) {
if (route.path.endsWith('collections')) {
return redirect(`/${prefix}/explore/collectibles`)
Expand All @@ -8,4 +9,8 @@ export default function ({ store, redirect, route }): void {
return redirect(`/${prefix}/explore/items`)
}
}

if (route.path.includes('/rmrk2/')) {
return redirect(window.location.href.replace('/rmrk2/', '/ksm/'))
}
}
17 changes: 17 additions & 0 deletions tests/cypress/e2e/redirect.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('redirect middleware', () => {
it('should redirect from rmrk2 prefix to ksm', () => {
cy.visit(
'/rmrk2/gallery/17842583-22708b368d163c8007-CITY-LOWER_ART_DISTRICT-00000006'
)
cy.url().should(
'include',
'/ksm/gallery/17842583-22708b368d163c8007-CITY-LOWER_ART_DISTRICT-00000006'
)

cy.visit('/rmrk2/explore/items?listed=true&sort=updatedAt_DESC')
cy.url().should(
'include',
'/ksm/explore/items?listed=true&sort=updatedAt_DESC'
)
})
})

0 comments on commit 7a14f72

Please sign in to comment.