mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[api-minor] Improve the FileSpec
implementation
- Check that the `filename` is actually a string, before parsing it further. - Use proper "shadowing" in the `filename` getter. - Add a bit more validation of the data in `pickPlatformItem`. - Last, but not least, return both the original `filename` and the (path stripped) variant needed in the display-layer and viewer.
This commit is contained in:
parent
16dbf5dcfd
commit
2b69fb76ac
6 changed files with 47 additions and 46 deletions
|
@ -37,7 +37,6 @@ import {
|
|||
} from "../shared/util.js";
|
||||
import {
|
||||
DOMSVGFactory,
|
||||
getFilenameFromUrl,
|
||||
PDFDateString,
|
||||
setLayerDimensions,
|
||||
} from "./display_utils.js";
|
||||
|
@ -2859,15 +2858,13 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
constructor(parameters) {
|
||||
super(parameters, { isRenderable: true });
|
||||
|
||||
const { filename, content, description } = this.data.file;
|
||||
this.filename = getFilenameFromUrl(filename, /* onlyStripPath = */ true);
|
||||
this.content = content;
|
||||
const { file } = this.data;
|
||||
this.filename = file.filename;
|
||||
this.content = file.content;
|
||||
|
||||
this.linkService.eventBus?.dispatch("fileattachmentannotation", {
|
||||
source: this,
|
||||
filename,
|
||||
content,
|
||||
description,
|
||||
...file,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue