Adjust encoding/decoding

This commit is contained in:
Will Boyd
2020-12-29 16:41:38 -05:00
parent f879a2e3fb
commit 56bbc4f16b
3 changed files with 9 additions and 6 deletions
+4 -1
View File
@@ -134,10 +134,13 @@ async function writeImageFilesPromise(posts, config) {
}
async function loadImageFilePromise(imageUrl) {
// only encode the URL if it doesn't already have encoded characters
const url = (/%[\da-f]{2}/i).test(imageUrl) ? imageUrl : encodeURI(imageUrl);
let buffer;
try {
buffer = await requestPromiseNative.get({
url: encodeURI(imageUrl),
url,
encoding: null, // preserves binary encoding
headers: {
'User-Agent': 'wordpress-export-to-markdown'