Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Fix the back to results button for pages opened from collection pages (#4116)

Olga Bulat1bfe49e9ac80
diff --git a/frontend/src/middleware/single-result.ts b/frontend/src/middleware/single-result.ts
index e9a2a6d47..8ccf9fc79 100644
--- a/frontend/src/middleware/single-result.ts
+++ b/frontend/src/middleware/single-result.ts
@@ -8,8 +8,7 @@ import { AUDIO, IMAGE } from "~/constants/media"
import type { Middleware } from "@nuxt/types"
const isSearchPath = (path: string) => path.includes("/search/")
-const isSearchOrCollectionPath = (path: string) =>
- isSearchPath(path) || path.includes("/source/") || path.includes("/tag/")
+const isCollectionPath = (path: string) => path.includes("/collection")
export const singleResultMiddleware: Middleware = async ({
route,
@@ -35,7 +34,7 @@ export const singleResultMiddleware: Middleware = async ({
// Client-side rendering
singleResultStore.setMediaById(mediaType, route.params.id)
- if (from && isSearchOrCollectionPath(from.path)) {
+ if (from && (isSearchPath(from.path) || isCollectionPath(from.path))) {
const searchStore = useSearchStore($pinia)
searchStore.setBackToSearchPath(from.fullPath)