From 0d1ed12b64968a43c90cc6d17d354dc19d46df87 Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Sat, 28 Nov 2020 16:03:59 +0000 Subject: [PATCH] chore: Build Project --- packages/react-multi-crop/dist/index.cjs.js | 30 ++++++++++++++++----- packages/react-multi-crop/dist/index.esm.js | 30 ++++++++++++++++----- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/packages/react-multi-crop/dist/index.cjs.js b/packages/react-multi-crop/dist/index.cjs.js index b57eac8a9..de1df0fec 100644 --- a/packages/react-multi-crop/dist/index.cjs.js +++ b/packages/react-multi-crop/dist/index.cjs.js @@ -147,6 +147,7 @@ var ReactMultiCrop = /*#__PURE__*/function (_Component) { canvas: null, initial: true }; + _this.REGEXP_ORIGINS = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i; _this.color = props.cropBackgroundColor; _this.opacity = props.cropBackgroundOpacity; _this.strokeColor = props.cropOutlineColor; @@ -210,6 +211,12 @@ var ReactMultiCrop = /*#__PURE__*/function (_Component) { }, this.initialObjects.bind(this)); } } + }, { + key: "isCrossOriginURL", + value: function isCrossOriginURL(url) { + var parts = url.match(this.REGEXP_ORIGINS); + return parts !== null && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port); + } }, { key: "initialImage", value: function initialImage() { @@ -219,13 +226,24 @@ var ReactMultiCrop = /*#__PURE__*/function (_Component) { var loadImageNow = this.loadImage.bind(this); if (_typeof(record) === "object" && record.image) { - fabric.fabric.Image.fromURL(record.image, loadImageNow, { - crossOrigin: "Anonymous" - }); + var isCrossOrigin = this.isCrossOriginURL(record.image); + var options = {}; + + if (isCrossOrigin) { + options.crossOrigin = "Anonymous"; + } + + fabric.fabric.Image.fromURL(record.image, loadImageNow, options); } else if (typeof image === "string") { - fabric.fabric.Image.fromURL(image, loadImageNow, { - crossOrigin: "Anonymous" - }); + var _isCrossOrigin = this.isCrossOriginURL(image); + + var _options = {}; + + if (_isCrossOrigin) { + _options.crossOrigin = "Anonymous"; + } + + fabric.fabric.Image.fromURL(image, loadImageNow, _options); } } }, { diff --git a/packages/react-multi-crop/dist/index.esm.js b/packages/react-multi-crop/dist/index.esm.js index e3a077299..d267580ca 100644 --- a/packages/react-multi-crop/dist/index.esm.js +++ b/packages/react-multi-crop/dist/index.esm.js @@ -136,6 +136,7 @@ var ReactMultiCrop = /*#__PURE__*/function (_Component) { canvas: null, initial: true }; + _this.REGEXP_ORIGINS = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i; _this.color = props.cropBackgroundColor; _this.opacity = props.cropBackgroundOpacity; _this.strokeColor = props.cropOutlineColor; @@ -199,6 +200,12 @@ var ReactMultiCrop = /*#__PURE__*/function (_Component) { }, this.initialObjects.bind(this)); } } + }, { + key: "isCrossOriginURL", + value: function isCrossOriginURL(url) { + var parts = url.match(this.REGEXP_ORIGINS); + return parts !== null && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port); + } }, { key: "initialImage", value: function initialImage() { @@ -208,13 +215,24 @@ var ReactMultiCrop = /*#__PURE__*/function (_Component) { var loadImageNow = this.loadImage.bind(this); if (_typeof(record) === "object" && record.image) { - fabric.Image.fromURL(record.image, loadImageNow, { - crossOrigin: "Anonymous" - }); + var isCrossOrigin = this.isCrossOriginURL(record.image); + var options = {}; + + if (isCrossOrigin) { + options.crossOrigin = "Anonymous"; + } + + fabric.Image.fromURL(record.image, loadImageNow, options); } else if (typeof image === "string") { - fabric.Image.fromURL(image, loadImageNow, { - crossOrigin: "Anonymous" - }); + var _isCrossOrigin = this.isCrossOriginURL(image); + + var _options = {}; + + if (_isCrossOrigin) { + _options.crossOrigin = "Anonymous"; + } + + fabric.Image.fromURL(image, loadImageNow, _options); } } }, {