Skip to content

Commit

Permalink
Find file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Feb 5, 2024
1 parent d75fd79 commit 161c6ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions services/ansible_openvpn/docker/dashboard/app/static/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,15 @@ async function do_decrypt(jsonContent) {
// outputs decrypted hex
// Create regex patterns for replacing unwanted characters in file name
const formattedDate = jsonContent.date.replace(new RegExp(`[-:]`, 'g'), "_");
const fname = jsonContent.hwa+"_"+formattedDate+".flac";
download(decipher.output.data, fname, "audio/flac");
let format = "raw";
// look for magic word in file header
if(decipher.output.data.substring(0,4) == "fLaC") {
format = "flac";
} else if(decipher.output.data.substring(0,3) == "Ogg") {
format = "ogg";
}
const fname = jsonContent.hwa+"_"+formattedDate+"."+format;
download(decipher.output.data, fname, "audio/"+format);
}
} catch (e) {
el.style.visibility = "visible";
Expand Down

0 comments on commit 161c6ad

Please sign in to comment.