better content type handling

This commit is contained in:
Luck
2021-03-27 13:09:03 +00:00
parent c8e687d67d
commit e790c54b56
2 changed files with 21 additions and 7 deletions

View File

@@ -147,10 +147,18 @@ const MenuButton = ({ label, ids, value, setValue }) => {
)
}
function langaugeToContentType(language) {
if (language === 'json') {
return 'application/json';
} else {
return 'text/' + language;
}
}
async function saveToBytebin(code, language) {
try {
const compressed = gzip(code);
const contentType = 'text/' + language;
const contentType = langaugeToContentType(language);
const resp = await fetch('https://bytebin.lucko.me/post', {
method: 'POST',