Skip to content

Commit

Permalink
add Olivier proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Aug 21, 2023
1 parent 6edc2f6 commit 5fbebb3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/src/modules/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ export function pathnameToLanguage(pathname: string): {
// Remove hash as it's never sent to the server
// https://github.com/vercel/next.js/issues/25202
const canonicalAsServer = canonicalAs.replace(/#(.*)$/, '');
const canonicalPathname = canonicalAsServer.replace(/^\/api/, '/api-docs').replace(/\/$/, '');

let canonicalPathname = canonicalAsServer.replace(/^\/api/, '/api-docs');

// Remove trailing slash as Next.js doesn't expect it here
// https://nextjs.org/docs/pages/api-reference/functions/use-router#router-object
if (canonicalPathname !== '/') {
canonicalPathname = canonicalPathname.replace(/\/$/, '');
}

return {
userLanguage,
Expand Down

0 comments on commit 5fbebb3

Please sign in to comment.