@eshal-bot/chat-widget 0.1.75 → 0.1.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-widget.esm.js +1 -1
- package/dist/chat-widget.js +28 -3
- package/dist/chat-widget.min.js +1 -1
- package/dist/chat-widget.umd.js +1 -1
- package/package.json +1 -1
package/dist/chat-widget.js
CHANGED
|
@@ -94490,12 +94490,37 @@
|
|
|
94490
94490
|
const downloadKey = _downloadKey(source) || "attachment";
|
|
94491
94491
|
setDownloadingId(downloadKey);
|
|
94492
94492
|
try {
|
|
94493
|
+
// 2026-07-03 — user reported the download dialog was
|
|
94494
|
+
// suggesting the storage-key blob name (e.g. `<uuid>-
|
|
94495
|
+
// RishabhResume.pdf`) instead of the original filename.
|
|
94496
|
+
// Root cause: the server behind `/api/v1/files/...` sends
|
|
94497
|
+
// a `Content-Disposition: attachment; filename=<blob>`
|
|
94498
|
+
// header, and browsers give that precedence over the
|
|
94499
|
+
// `<a download="…">` attribute. Workaround: fetch the
|
|
94500
|
+
// bytes into a Blob, mint an object URL, and use `a.download`
|
|
94501
|
+
// — object URLs have no `Content-Disposition` so the
|
|
94502
|
+
// attribute wins and the user gets the pretty filename.
|
|
94503
|
+
// Same pattern the KB /file-download branch below uses.
|
|
94504
|
+
const fetchHeaders = {};
|
|
94505
|
+
if (typeof getAuthToken === "function") {
|
|
94506
|
+
const token = await getAuthToken();
|
|
94507
|
+
if (token) fetchHeaders["Authorization"] = "Bearer ".concat(token);
|
|
94508
|
+
}
|
|
94509
|
+
const res = await fetch(source.url, {
|
|
94510
|
+
method: "GET",
|
|
94511
|
+
headers: fetchHeaders,
|
|
94512
|
+
credentials: "include"
|
|
94513
|
+
});
|
|
94514
|
+
if (!res.ok) {
|
|
94515
|
+
throw new Error("Attachment fetch failed: ".concat(res.status));
|
|
94516
|
+
}
|
|
94517
|
+
const blob = await res.blob();
|
|
94518
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
94493
94519
|
const a = document.createElement("a");
|
|
94494
|
-
a.href =
|
|
94520
|
+
a.href = objectUrl;
|
|
94495
94521
|
a.download = source.source_name || "download";
|
|
94496
|
-
a.target = "_blank";
|
|
94497
|
-
a.rel = "noopener noreferrer";
|
|
94498
94522
|
a.click();
|
|
94523
|
+
URL.revokeObjectURL(objectUrl);
|
|
94499
94524
|
} catch (e) {
|
|
94500
94525
|
console.error("Attachment download failed:", e);
|
|
94501
94526
|
} finally {
|