Skip to content

Commit

Permalink
Improve .zip support
Browse files Browse the repository at this point in the history
  • Loading branch information
mbloch committed Dec 22, 2022
1 parent b09620d commit 3705f7c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/gui/gui-zip-reader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GUI.readZipFile = function(file, cb) {
function readEntry(entry) {
var filename = entry.filename,
isValid = !entry.directory && GUI.isReadableFileType(filename) &&
!/^__MACOSX/.test(filename); // ignore "resource-force" files
!/^__MACOSX/.test(filename); // ignore "resource-fork" files
if (isValid) {
entry.getData(new zip.BlobWriter(), function(file) {
file.name = filename; // Give the Blob a name, like a File object
Expand Down
2 changes: 1 addition & 1 deletion src/io/mapshaper-zip.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function extractFiles(input, cache) {
// don't import .dbf separately if .shp is present
if (replaceFileExtension(file, 'shp') in cache) return false;
}
return type == 'text' || type == 'json' || type == 'shp' || type == 'dbf';
return type == 'text' || type == 'json' || type == 'shp' || type == 'dbf' || type == 'kml';
});
}

Expand Down
Binary file added test/data/features/zip/zip-in-zip.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions test/zip-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@ describe('zip i/o', function () {
assert.deepEqual(data, target);
});

it('Unable to import zip in zip', async function() {
var file = 'test/data/features/zip/zip-in-zip.zip';
var cmd = `-i ${file} -o data.zip`;
try {
await api.applyCommands(cmd);
} catch(e) {
assert.equal(e.name, 'UserError');
}
})

});

0 comments on commit 3705f7c

Please sign in to comment.