aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json2
-rw-r--r--package.json2
-rw-r--r--src/components/UploadImage/UploadImage.tsx21
3 files changed, 9 insertions, 16 deletions
diff --git a/package-lock.json b/package-lock.json
index 41430ec..0f360a2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "which",
- "version": "0.1.0",
+ "version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 9d7e0a7..f3ab8c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "which",
- "version": "1.0.0",
+ "version": "1.0.1",
"homepage": "https://ilyayudovin.github.io/which",
"dependencies": {
"@material-ui/core": "^4.10.1",
diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx
index 836b2a0..5b2f38e 100644
--- a/src/components/UploadImage/UploadImage.tsx
+++ b/src/components/UploadImage/UploadImage.tsx
@@ -6,9 +6,7 @@ import {
DialogActions,
DialogContent,
DialogContentText,
- DialogTitle,
- FormControlLabel,
- Switch
+ DialogTitle
} from '@material-ui/core';
interface PropTypes {
@@ -19,15 +17,18 @@ interface PropTypes {
const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
const [url, setUrl] = useState<string>('');
- const [isInstagramLink, setIsInstagramLink] = useState<boolean>(false);
-
const handleClose = () => {
setIsOpen(false);
};
const handleSubmit = () => {
- const result = isInstagramLink ? `${url.slice(0, url.length - 29)}/media/?size=l` : url;
+ let result = url;
+ if (url.startsWith('https://www.instagram.com/')) {
+ const lastSlashIndex = url.lastIndexOf('/');
+ const baseUrl = url.slice(0, lastSlashIndex);
+ result = `${baseUrl}/media/?size=l`;
+ }
callback(result || '');
handleClose();
};
@@ -36,10 +37,6 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
setUrl(event.target.value);
};
- const handleSwitch = () => {
- setIsInstagramLink(!isInstagramLink);
- };
-
return (
<div>
<Dialog open={isOpen} onClose={handleClose}>
@@ -58,10 +55,6 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
autoComplete="off"
onChange={handleChange}
/>
- <FormControlLabel
- control={<Switch color="primary" onClick={handleSwitch} checked={isInstagramLink} size="small" />}
- label="It's an Instagram link"
- />
</DialogContent>
<DialogActions>
<Button onClick={handleClose} color="primary">