fix: sharex DestinationType

This commit is contained in:
diced 2023-01-18 09:05:12 -08:00
parent 59b3e5bb24
commit 4e27efb6a1
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -1,11 +1,12 @@
import { useState } from 'react';
import { useReducer, useState } from 'react';
import { GeneratorModal } from './GeneratorModal';
export default function ShareX({ user, open, setOpen }) {
const [config, setConfig] = useState({
const onSubmit = (values) => {
const config = {
Version: '14.1.0',
Name: 'Zipline',
DestinationType: 'ImageUploader, TextUploader',
DestinationType: 'ImageUploader, TextUploader, FileUploader',
RequestMethod: 'POST',
RequestURL: `${
window.location.protocol +
@ -20,9 +21,8 @@ export default function ShareX({ user, open, setOpen }) {
Body: 'MultipartFormData',
FileFormName: 'file',
Data: undefined,
});
};
const onSubmit = (values) => {
if (values.type === 'shorten-url') {
config.RequestURL = `${
window.location.protocol +
@ -32,62 +32,49 @@ export default function ShareX({ user, open, setOpen }) {
}/api/shorten`;
config.URL = '$json:url$';
config.Body = 'JSON';
config.DestinationType = 'URLShortener';
delete config.FileFormName;
config.Data = JSON.stringify({ url: '{input}' });
setConfig(config);
} else {
delete config.Data;
setConfig(config);
}
if (values.format !== 'RANDOM' && values.type === 'upload-file') {
config.Headers['Format'] = values.format;
setConfig(config);
} else {
delete config.Headers['Format'];
setConfig(config);
}
if (values.imageCompression !== 0 && values.type === 'upload-file') {
config.Headers['Image-Compression-Percent'] = values.imageCompression;
setConfig(config);
} else {
delete config.Headers['Image-Compression-Percent'];
setConfig(config);
}
if (values.zeroWidthSpace) {
config.Headers['Zws'] = 'true';
setConfig(config);
} else {
delete config.Headers['Zws'];
setConfig(config);
}
if (values.embed && values.type === 'upload-file') {
config.Headers['Embed'] = 'true';
setConfig(config);
} else {
delete config.Headers['Embed'];
setConfig(config);
}
if (values.noJSON) {
config.URL = '{response}';
config.Headers['No-JSON'] = 'true';
setConfig(config);
} else {
delete config.Headers['No-JSON'];
config.URL = values.type === 'upload-file' ? '$json:files[0]$' : '$json:url$';
setConfig(config);
}
if (values.originalName && values.type === 'upload-file') {
config.Headers['Original-Name'] = 'true';
setConfig(config);
} else {
delete config.Headers['Original-Name'];
setConfig(config);
}
const pseudoElement = document.createElement('a');