Skip to content

Commit

Permalink
fix(v2): Unbreak blog-only mode routing by deplicating starting forwa…
Browse files Browse the repository at this point in the history
…rd slashes
  • Loading branch information
SamChou19815 committed Apr 2, 2020
1 parent 686c8ae commit 7194abb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/docusaurus-utils/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ describe('load utils', () => {
input: ['/test/', '/', 'ro', 'doc1'],
output: '/test/ro/doc1',
},
{
input: ['/', '/', '2020/02/29/leap-day'],
output: '/2020/02/29/leap-day',
},
{
input: ['', '/', 'ko', 'hello'],
output: '/ko/hello',
Expand Down
3 changes: 3 additions & 0 deletions packages/docusaurus-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ export function normalizeUrl(rawUrls: string[]): string {
// Dedupe forward slashes in the entire path, avoiding protocol slashes.
str = str.replace(/([^:]\/)\/+/g, '$1');

// Dedupe forward slashes at the beginning of the path.
str = str.replace(/^\/+/g, '/');

return str;
}

Expand Down

0 comments on commit 7194abb

Please sign in to comment.