@ecodev/natural 47.3.1 → 47.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8632,16 +8632,27 @@ function createFileInput(document) {
|
|
|
8632
8632
|
return fileElem;
|
|
8633
8633
|
}
|
|
8634
8634
|
function isDirectory(file) {
|
|
8635
|
-
return file
|
|
8636
|
-
.slice(0, 1)
|
|
8637
|
-
.text()
|
|
8638
|
-
.then(text => {
|
|
8635
|
+
return blobText(file.slice(0, 1)).then(text => {
|
|
8639
8636
|
// Firefox will return empty string for a folder, so we must check that special case.
|
|
8640
8637
|
// That means that any empty file will incorrectly be interpreted as a folder on all
|
|
8641
8638
|
// browsers, but that's tolerable because there is no real use-case to upload an empty file.
|
|
8642
8639
|
return text !== '';
|
|
8643
8640
|
}, () => false);
|
|
8644
8641
|
}
|
|
8642
|
+
/**
|
|
8643
|
+
* This is a ponyfill for `Blob.text()`, because Safari 13 and 14 do not support it, https://caniuse.com/?search=blob.text,
|
|
8644
|
+
* and we try our best not to break iPhone users too much.
|
|
8645
|
+
*/
|
|
8646
|
+
function blobText(blob) {
|
|
8647
|
+
return new Promise((resolve, reject) => {
|
|
8648
|
+
const reader = new FileReader();
|
|
8649
|
+
reader.onload = () => {
|
|
8650
|
+
resolve(reader.result);
|
|
8651
|
+
};
|
|
8652
|
+
reader.onerror = reject;
|
|
8653
|
+
reader.readAsText(blob);
|
|
8654
|
+
});
|
|
8655
|
+
}
|
|
8645
8656
|
function stopEvent(event) {
|
|
8646
8657
|
event.preventDefault();
|
|
8647
8658
|
event.stopPropagation();
|