Use absolute URLs for logos (#161)

This commit is contained in:
Samy Pessé
2024-02-15 10:06:05 +01:00
committed by GitHub
parent 0b620640fa
commit ebdec4966b
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -102,11 +102,11 @@ function LogoFallback(props: HeaderLogoProps) {
}
: {
light: {
src: absoluteHref('~gitbook/icon?size=medium&theme=light'),
src: absoluteHref('~gitbook/icon?size=medium&theme=light', true),
size: { width: 256, height: 256 },
},
dark: {
src: absoluteHref('~gitbook/icon?size=medium&theme=dark'),
src: absoluteHref('~gitbook/icon?size=medium&theme=dark', true),
size: { width: 256, height: 256 },
},
}
+9
View File
@@ -122,6 +122,15 @@ export async function resizeImage(
): Promise<Response> {
const { signal, ...resizeOptions } = options;
const parsed = new URL(input);
if (parsed.protocol === 'data:') {
throw new Error('Cannot resize data: URLs');
}
if (parsed.hostname === 'localhost') {
throw new Error('Cannot resize localhost URLs');
}
// Since Cloudflare Images options on fetch are not supported on Cloudflare Pages,
// we need to use the Cloudflare Image Resize API directly.
if (process.env.GITBOOK_IMAGE_RESIZE_URL) {