fix(v2): unbreak blog-only mode routing by deplicating starting forward slashes (#2497)

This commit is contained in:
Sam Zhou 2020-04-01 23:02:44 -04:00 committed by GitHub
parent d1326cdee8
commit da7fd1a186
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -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',

View file

@ -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;
}