Skip to content

Commit a0aad14

Browse files
committed
Preserve the path when redirecting the latest version
1 parent a95d95b commit a0aad14

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/middleware.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ export function middleware(request: NextRequest) {
4848
if (pathWithoutBase.startsWith(`/v/${docsConfig.DOCS_LATEST_VERSION}/`)) {
4949
return NextResponse.redirect(createRedirectUrl(
5050
request,
51-
`https://sourcegraph.com/docs/:slug*`,
52-
pathWithoutBase
51+
pathWithoutBase.substring(`/v/${docsConfig.DOCS_LATEST_VERSION}/`.length - 1),
52+
""
5353
))
5454
}
5555
if (pathWithoutBase.startsWith(`/@${docsConfig.DOCS_LATEST_VERSION}/`)) {
5656
return NextResponse.redirect(createRedirectUrl(
5757
request,
58-
`https://sourcegraph.com/docs/:slug*`,
59-
pathWithoutBase
58+
pathWithoutBase.substring(`/@${docsConfig.DOCS_LATEST_VERSION}/`.length - 1),
59+
""
6060
))
6161
}
6262
const versionMatch = pathWithoutBase.match(/^\/v\/(\d+\.\d+)\/(.*)/)

0 commit comments

Comments
 (0)