Update test + implementation

This commit is contained in:
Steven Hall
2025-06-18 11:19:05 +01:00
parent 10ec32765d
commit d96848ba6d
2 changed files with 5 additions and 9 deletions
+1 -5
View File
@@ -259,11 +259,7 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
console.log(`rewriting ${request.nextUrl.toString()} to ${route}`);
const rewrittenURL = new URL(`/${route}`, request.nextUrl.toString());
// Ensure all searchParams are brought over to the rewritten URL
request.nextUrl.searchParams.forEach((value, key) => {
rewrittenURL.searchParams.set(key, value);
});
rewrittenURL.search = request.nextUrl.search; // Preserve the original search params
const response = NextResponse.rewrite(rewrittenURL, {
request: {
+4 -4
View File
@@ -82,11 +82,11 @@ const testCases: TestsCase[] = [
},
{
name: 'PDF (all pages)',
url: '~gitbook/pdf?limit=100',
url: '~gitbook/pdf?limit=10',
},
{
name: 'PDF (only current page)',
url: '~gitbook/pdf?page=Bw7LjWwgTjV8nIV4s7rs&only=yes&limit=100',
url: '~gitbook/pdf?page=Bw7LjWwgTjV8nIV4s7rs&only=yes&limit=2',
},
{
name: 'Not found',
@@ -316,11 +316,11 @@ const testCases: TestsCase[] = [
},
{
name: 'PDF (all pages)',
url: '~gitbook/pdf?limit=100',
url: '~gitbook/pdf?limit=10',
},
{
name: 'PDF (only current page)',
url: '~gitbook/pdf?page=DfnNkU49mvLe2ythHAyx&only=yes&limit=100',
url: '~gitbook/pdf?page=DfnNkU49mvLe2ythHAyx&only=yes&limit=2', // limit 2 pages to catch any bugs with multiple pages
},
{
name: 'Not found',