Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/archive-filesystem-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function decodeSourceArchiveUri(uri: vscode.Uri): ZipFileReference {
// Uri is malformed, but this is recoverable
logger.log(`Warning: ${new InvalidSourceArchiveUriError(uri).message}`);
return {
pathWithinSourceArchive: '',
pathWithinSourceArchive: '/',
sourceArchiveZipPath: uri.path
};
}
Expand All @@ -129,7 +129,7 @@ export function decodeSourceArchiveUri(uri: vscode.Uri): ZipFileReference {
if (isNaN(zipPathStartIndex) || isNaN(zipPathEndIndex))
throw new InvalidSourceArchiveUriError(uri);
return {
pathWithinSourceArchive: uri.path.substring(zipPathEndIndex),
pathWithinSourceArchive: uri.path.substring(zipPathEndIndex) || '/',
sourceArchiveZipPath: uri.path.substring(zipPathStartIndex, zipPathEndIndex),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('source archive uri encoding', function() {
name: 'Empty path',
input: {
sourceArchiveZipPath: '/home/folder/src.zip',
pathWithinSourceArchive: ''
pathWithinSourceArchive: '/'
}
}
];
Expand All @@ -153,11 +153,22 @@ describe('source archive uri encoding', function() {
});
}

it('should decode an empty path as a "/"', () => {
const uri = encodeSourceArchiveUri({
pathWithinSourceArchive: '',
sourceArchiveZipPath: 'a/b/c'
});
expect(decodeSourceArchiveUri(uri)).to.deep.eq({
pathWithinSourceArchive: '/',
sourceArchiveZipPath: 'a/b/c'
});
});

it('should encode a uri at the root of the archive', () => {
const path = '/a/b/c/src.zip';
const uri = encodeArchiveBasePath(path);
expect(uri.path).to.eq(path);
expect(decodeSourceArchiveUri(uri).pathWithinSourceArchive).to.eq('');
expect(decodeSourceArchiveUri(uri).pathWithinSourceArchive).to.eq('/');
expect(decodeSourceArchiveUri(uri).sourceArchiveZipPath).to.eq(path);
expect(uri.authority).to.eq('0-14');
});
Expand All @@ -168,7 +179,7 @@ describe('source archive uri encoding', function() {
expect(uri.authority).to.eq('');
expect(decodeSourceArchiveUri(uri)).to.deep.eq({
sourceArchiveZipPath: '/a/b/c/src.zip',
pathWithinSourceArchive: ''
pathWithinSourceArchive: '/'
});
});
});