Skip to content

Commit

Permalink
fix(GitHub Node): Don't truncate filenames retrieved from GitHub (#12923
Browse files Browse the repository at this point in the history
)

Co-authored-by: Dana Lee <dana@n8n.io>
  • Loading branch information
Mariana-na and dana-gill authored Jan 31, 2025
1 parent b77bf86 commit 7e18447
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
22 changes: 22 additions & 0 deletions packages/core/src/__tests__/node-execute-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
parseContentType,
parseIncomingMessage,
parseRequestObject,
prepareBinaryData,
proxyRequestToAxios,
removeEmptyBody,
setBinaryDataBuffer,
Expand Down Expand Up @@ -94,6 +95,27 @@ describe('NodeExecuteFunctions', () => {
expect(getBinaryDataBufferResponse).toEqual(inputData);
});

test('test prepareBinaryData parses filenames correctly', async () => {
const filenameExpected = [
{
filename: 't?ext',
expected: 't?ext',
},
{
filename: 'no-symbol',
expected: 'no-symbol',
},
];

for (const { filename, expected } of filenameExpected) {
const binaryData: Buffer = Buffer.from('This is some binary data', 'utf8');

const result = await prepareBinaryData(binaryData, 'workflowId', 'executionId', filename);

expect(result.fileName).toEqual(expected);
}
});

test("test getBinaryDataBuffer(...) & setBinaryDataBuffer(...) methods in 'filesystem' mode", async () => {
Container.set(BinaryDataService, new BinaryDataService());

Expand Down
7 changes: 1 addition & 6 deletions packages/core/src/node-execute-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,12 +1202,7 @@ export async function prepareBinaryData(
};

if (filePath) {
if (filePath.includes('?')) {
// Remove maybe present query parameters
filePath = filePath.split('?').shift();
}

const filePathParts = path.parse(filePath as string);
const filePathParts = path.parse(filePath);

if (filePathParts.dir !== '') {
returnData.directory = filePathParts.dir;
Expand Down

0 comments on commit 7e18447

Please sign in to comment.