Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FilePicker): path can now start with a dot #544

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
8 changes: 4 additions & 4 deletions libs/execution/src/lib/types/io-types/filesystem-inmemory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export class InMemoryFileSystem implements FileSystem {
}

private processPath(path: string): string[] | null {
if (!path.startsWith(InMemoryFileSystem.getPathSeparator())) {
const [head, ...tail] = path.split(InMemoryFileSystem.getPathSeparator());
if (!(head === '' || head === InMemoryFileSystem.CURRENT_DIR)) {
return null;
}
const parts = path
.split(InMemoryFileSystem.getPathSeparator())
.filter((p) => p !== ''); // Process paths like "folder1//folder1" to "folder1/folder2"

const parts = tail.filter((p) => p !== ''); // Process paths like "folder1//folder1" to "folder1/folder2"
const processedParts: string[] = [];
for (const part of parts) {
if (part === InMemoryFileSystem.CURRENT_DIR) {
Expand Down
19 changes: 19 additions & 0 deletions libs/extensions/std/exec/src/file-picker-executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,23 @@ describe('Validation of FilePickerExecutor', () => {
expect(result.left.message).toEqual(`File '/test.txt' not found`);
}
});

it('should work if the filename starts with a dot', async () => {
const text = readJvTestAsset('dot-valid-file-picker.jv');
uploadTestFile('test.txt');

const result = await parseAndExecuteArchiveInterpreter(text, fileSystem);

expect(R.isErr(result)).toEqual(false);
if (R.isOk(result)) {
expect(result.right).toEqual(
expect.objectContaining({
name: 'test.txt',
extension: 'txt',
ioType: IOType.FILE,
mimeType: R.MimeType.TEXT_PLAIN,
}),
);
}
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg
//
// SPDX-License-Identifier: AGPL-3.0-only

pipeline TestPipeline {

block TestExtractor oftype TestFileExtractor {
}

block TestBlock oftype FilePicker {
path: './test.txt';
}

block TestLoader oftype TestFileLoader {
}

TestExtractor -> TestBlock -> TestLoader;
}
Loading