File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -16,21 +16,21 @@ type URLWithMode = { url: URL; mode: 'url' | 'url-host' };
16
16
17
17
export async function middleware ( request : NextRequest ) {
18
18
try {
19
- /**
20
- * Serve image resizing requests (all requests containing `/~gitbook/image`).
21
- * All URLs containing `/~gitbook/image` are rewritten to `/~gitbook/image`
22
- * and serve from a single route handler.
23
- *
24
- * In GitBook v1: image resizing was done at the root of the hostname (docs.company.com/~gitbook/image)
25
- * In GitBook v2: image resizing is done at the content level (docs.company.com/section/variant/~gitbook/image)
26
- */
27
- if ( request . nextUrl . pathname . endsWith ( '/~gitbook/image' ) ) {
28
- return serveResizedImage ( request ) ;
29
- }
30
-
31
19
// Route all requests to a site
32
20
const extracted = extractURL ( request ) ;
33
21
if ( extracted ) {
22
+ /**
23
+ * Serve image resizing requests (all requests containing `/~gitbook/image`).
24
+ * All URLs containing `/~gitbook/image` are rewritten to `/~gitbook/image`
25
+ * and serve from a single route handler.
26
+ *
27
+ * In GitBook v1: image resizing was done at the root of the hostname (docs.company.com/~gitbook/image)
28
+ * In GitBook v2: image resizing is done at the content level (docs.company.com/section/variant/~gitbook/image)
29
+ */
30
+ if ( extracted . url . pathname . endsWith ( '/~gitbook/image' ) ) {
31
+ return serveResizedImage ( request ) ;
32
+ }
33
+
34
34
return serveSiteByURL ( request , extracted ) ;
35
35
}
36
36
You can’t perform that action at this time.
0 commit comments