aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PDFBox.tsx
diff options
context:
space:
mode:
authorLionel Han <47760119+IGoByJoe@users.noreply.github.com>2020-06-29 14:42:36 -0700
committerLionel Han <47760119+IGoByJoe@users.noreply.github.com>2020-06-29 14:42:36 -0700
commit2646aa86bc6d676e848028601f9a4fedeefe35be (patch)
tree42d208346a283f788268c9d74de7dcc835bd84a6 /src/client/views/nodes/PDFBox.tsx
parent992a65ec6f828dda0adcd3cd121896f07f64af87 (diff)
parent73bbc602fb964c82999faccfdde8eeca6fbf08c4 (diff)
pull
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
-rw-r--r--src/client/views/nodes/PDFBox.tsx37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index c1a0be9ea..54f44a0f9 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -55,25 +55,28 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps, PdfDocum
const backup = "oldPath";
const { Document } = this.props;
- const { url: { href } } = Cast(this.dataDoc[this.props.fieldKey], PdfField)!;
- const pathCorrectionTest = /upload\_[a-z0-9]{32}.(.*)/g;
- const matches = pathCorrectionTest.exec(href);
- console.log("\nHere's the { url } being fed into the outer regex:");
- console.log(href);
- console.log("And here's the 'properPath' build from the captured filename:\n");
- if (matches !== null && href.startsWith(window.location.origin)) {
- const properPath = Utils.prepend(`/files/pdfs/${matches[0]}`);
- console.log(properPath);
- if (!properPath.includes(href)) {
- console.log(`The two (url and proper path) were not equal`);
- const proto = Doc.GetProto(Document);
- proto[this.props.fieldKey] = new PdfField(properPath);
- proto[backup] = href;
+ const pdf = Cast(this.dataDoc[this.props.fieldKey], PdfField);
+ const href = pdf?.url?.href;
+ if (href) {
+ const pathCorrectionTest = /upload\_[a-z0-9]{32}.(.*)/g;
+ const matches = pathCorrectionTest.exec(href);
+ console.log("\nHere's the { url } being fed into the outer regex:");
+ console.log(href);
+ console.log("And here's the 'properPath' build from the captured filename:\n");
+ if (matches !== null && href.startsWith(window.location.origin)) {
+ const properPath = Utils.prepend(`/files/pdfs/${matches[0]}`);
+ console.log(properPath);
+ if (!properPath.includes(href)) {
+ console.log(`The two (url and proper path) were not equal`);
+ const proto = Doc.GetProto(Document);
+ proto[this.props.fieldKey] = new PdfField(properPath);
+ proto[backup] = href;
+ } else {
+ console.log(`The two (url and proper path) were equal`);
+ }
} else {
- console.log(`The two (url and proper path) were equal`);
+ console.log("Outer matches was null!");
}
- } else {
- console.log("Outer matches was null!");
}
}