From 4bb3a5f132167f8c113a5937cb3bc2347855c3b8 Mon Sep 17 00:00:00 2001 From: Matt Hamil Date: Mon, 12 Apr 2021 08:59:54 -0500 Subject: [PATCH] fix: #3822 blog links link correctly to blog posts in algolia search results --- components/AppSearchAlgolia.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/AppSearchAlgolia.vue b/components/AppSearchAlgolia.vue index 42397ad60b..76090bb4f8 100644 --- a/components/AppSearchAlgolia.vue +++ b/components/AppSearchAlgolia.vue @@ -29,7 +29,12 @@ export default { return url.replace(/\/$|\/(?=\?)|\/(?=#)/g, '') }, formatUrl(absoluteUrl) { - const { pathname, hash } = new URL(absoluteUrl) + const { pathname, hash, origin } = new URL(absoluteUrl) + + if (!origin.includes('docs.cypress.io')) { + return absoluteUrl + } + const url = pathname.replace(this.settings.url, '/') + hash return this.stripTrailingSlash(url)