fix: Unsure filename when downloading an untitled document
fix: Unsure unique filename when downloading revision
This commit is contained in:
@@ -759,6 +759,10 @@ class Document extends ParanoidModel {
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get titleWithDefault(): string {
|
||||||
|
return this.title || "Untitled";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of users that have collaborated on this document
|
* Get a list of users that have collaborated on this document
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -472,9 +472,9 @@ router.post(
|
|||||||
ctx.set("Content-Type", contentType);
|
ctx.set("Content-Type", contentType);
|
||||||
ctx.set(
|
ctx.set(
|
||||||
"Content-Disposition",
|
"Content-Disposition",
|
||||||
`attachment; filename="${slugify(document.title)}.${mime.extension(
|
`attachment; filename="${slugify(
|
||||||
contentType
|
document.titleWithDefault
|
||||||
)}"`
|
)}.${mime.extension(contentType)}"`
|
||||||
);
|
);
|
||||||
ctx.body = content;
|
ctx.body = content;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ router.post("revisions.diff", auth(), async (ctx) => {
|
|||||||
ctx.set("Content-Type", "text/html");
|
ctx.set("Content-Type", "text/html");
|
||||||
ctx.set(
|
ctx.set(
|
||||||
"Content-Disposition",
|
"Content-Disposition",
|
||||||
`attachment; filename="${slugify(document.title)}.html"`
|
`attachment; filename="${slugify(document.titleWithDefault)}-${
|
||||||
|
revision.id
|
||||||
|
}.html"`
|
||||||
);
|
);
|
||||||
ctx.body = content;
|
ctx.body = content;
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user