Files
MickaelK 7858b29cf5 fix (embed): Filestash embedding issue
whenever embedding something with a locale setup, it would crash while
trying to download the translation. This was due to some
missunderstanding of how fetch work while in an iframe and all the
reports would get miss because of that same issue as it was sent not to
the origin server but the website embedding the frame
2025-04-30 17:23:20 +10:00

16 lines
657 B
JavaScript

import { toHref } from "../lib/skeleton/router.js";
import ajax from "../lib/ajax.js";
export function report(msg, err, link, lineNo, columnNo) {
if (window.navigator.onLine === false) return Promise.resolve();
let url = toHref("/report?");
url += "url=" + encodeURIComponent(location.href) + "&";
url += "msg=" + encodeURIComponent(msg) + "&";
url += "from=" + encodeURIComponent(link) + "&";
url += "from.lineNo=" + lineNo + "&";
url += "from.columnNo=" + columnNo;
if (err instanceof Error) url += "error=" + encodeURIComponent(err.message) + "&";
return ajax({ url, method: "post" }).toPromise().catch(() => {});
}