From b6d39f5efa484152eb9688489f32d73eec250922 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 5 Jul 2020 18:55:47 +0300
Subject: fix: ignore instagram url appendix

---
 src/components/UploadImage/UploadImage.tsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/components/UploadImage/UploadImage.tsx')

diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx
index 5b2f38e..737c4df 100644
--- a/src/components/UploadImage/UploadImage.tsx
+++ b/src/components/UploadImage/UploadImage.tsx
@@ -25,8 +25,8 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
   const handleSubmit = () => {
     let result = url;
     if (url.startsWith('https://www.instagram.com/')) {
-      const lastSlashIndex = url.lastIndexOf('/');
-      const baseUrl = url.slice(0, lastSlashIndex);
+      const appendixIndex = url.indexOf('/?utm_source=');
+      const baseUrl = url.slice(0, appendixIndex);
       result = `${baseUrl}/media/?size=l`;
     }
     callback(result || '');
-- 
cgit v1.2.3

