/
githubmirror
/
tldraw
Обзор
Документация
Войти
/
githubmirror
/
tldraw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/utils/src/lib/network.ts
32 строки
1 KB
Kevin Ingersoll
refactor: enforce tldraw/no-exported-arrow-const repo-wide (#8947)
02 июн 2026, 11:54
Не верифицирован
02 июн 2026, 11:54
75852f8
Код
Авторство
О чём код?
/** * Just a wrapper around `window.fetch` that sets the `referrerPolicy` to `strict-origin-when-cross-origin`. * * @param input - A Request object or string containing the URL to fetch * @param init - Optional request initialization options * @returns Promise that resolves to the Response object * @internal */ export async function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> { // eslint-disable-next-line tldraw/no-restricted-properties return window.fetch(input, { // We want to make sure that the referrer is not sent to other domains. referrerPolicy: 'strict-origin-when-cross-origin', ...init, }) } /** * Just a wrapper around `new Image`, and yeah, it's a bit strange that it's in the network.ts file * but the main concern here is the referrerPolicy and setting it correctly. * * @param width - Optional width for the image element * @param height - Optional height for the image element * @returns HTMLImageElement with referrerPolicy set to 'strict-origin-when-cross-origin' * @internal */ export function Image(width?: number, height?: number) { // eslint-disable-next-line tldraw/no-restricted-properties const img = new window.Image(width, height) img.referrerPolicy = 'strict-origin-when-cross-origin' return img }