mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 11:26:31 +00:00
generate upto URL with 3 segments to support the new site url format (#2493)
Co-authored-by: Samy Pessé <samypesse@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'gitbook': minor
|
||||
---
|
||||
|
||||
Support resolution of new site URLs without the variant prefix /v/
|
||||
@@ -22,6 +22,11 @@ describe('getURLLookupAlternatives', () => {
|
||||
{
|
||||
extraPath: 'c',
|
||||
url: 'https://docs.mycompany.com/a/b',
|
||||
primary: false,
|
||||
},
|
||||
{
|
||||
extraPath: '',
|
||||
url: 'https://docs.mycompany.com/a/b/c',
|
||||
primary: true,
|
||||
},
|
||||
],
|
||||
@@ -229,6 +234,11 @@ describe('getURLLookupAlternatives', () => {
|
||||
{
|
||||
extraPath: 'c/d',
|
||||
url: 'https://docs.mycompany.com/a/b',
|
||||
primary: false,
|
||||
},
|
||||
{
|
||||
extraPath: 'd',
|
||||
url: 'https://docs.mycompany.com/a/b/c',
|
||||
primary: true,
|
||||
},
|
||||
],
|
||||
@@ -254,6 +264,11 @@ describe('getURLLookupAlternatives', () => {
|
||||
{
|
||||
extraPath: 'b/c/d',
|
||||
url: 'https://docs.mycompany.com/a/~',
|
||||
primary: false,
|
||||
},
|
||||
{
|
||||
extraPath: 'c/d',
|
||||
url: 'https://docs.mycompany.com/a/~/b',
|
||||
primary: true,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -91,7 +91,7 @@ export function getURLLookupAlternatives(input: URL) {
|
||||
}
|
||||
|
||||
// Otherwise match with the first two segments of the path
|
||||
for (let i = 1; i <= 2; i++) {
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
if (pathSegments.length >= i) {
|
||||
const shortURL = new URL(url);
|
||||
shortURL.pathname = pathSegments.slice(0, i).join('/');
|
||||
|
||||
Reference in New Issue
Block a user