mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 19:16:58 +02:00
fix(v2): unbreak blog-only mode routing by deplicating starting forward slashes (#2497)
This commit is contained in:
parent
d1326cdee8
commit
da7fd1a186
2 changed files with 7 additions and 0 deletions
|
@ -254,6 +254,10 @@ describe('load utils', () => {
|
||||||
input: ['/test/', '/', 'ro', 'doc1'],
|
input: ['/test/', '/', 'ro', 'doc1'],
|
||||||
output: '/test/ro/doc1',
|
output: '/test/ro/doc1',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: ['/', '/', '2020/02/29/leap-day'],
|
||||||
|
output: '/2020/02/29/leap-day',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
input: ['', '/', 'ko', 'hello'],
|
input: ['', '/', 'ko', 'hello'],
|
||||||
output: '/ko/hello',
|
output: '/ko/hello',
|
||||||
|
|
|
@ -256,6 +256,9 @@ export function normalizeUrl(rawUrls: string[]): string {
|
||||||
// Dedupe forward slashes in the entire path, avoiding protocol slashes.
|
// Dedupe forward slashes in the entire path, avoiding protocol slashes.
|
||||||
str = str.replace(/([^:]\/)\/+/g, '$1');
|
str = str.replace(/([^:]\/)\/+/g, '$1');
|
||||||
|
|
||||||
|
// Dedupe forward slashes at the beginning of the path.
|
||||||
|
str = str.replace(/^\/+/g, '/');
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue