fix(GitHub Node): Tolerate trailing slash in file path (#15517)

This commit is contained in:
Michael Kret
2025-06-17 18:21:57 +03:00
committed by GitHub
parent c64ccf74a2
commit 2f6896cc7b
6 changed files with 93 additions and 11 deletions

View File

@@ -25,6 +25,7 @@ import {
validateJSON,
} from './GenericFunctions';
import { getRefs, getRepositories, getUsers, getWorkflows } from './SearchFunctions';
import { removeTrailingSlash } from '../../utils/utilities';
import { defaultWebhookDescription } from '../Webhook/description';
export class Github implements INodeType {
@@ -2250,7 +2251,7 @@ export class Github implements INodeType {
requestMethod = 'PUT';
const filePath = this.getNodeParameter('filePath', i);
const filePath = removeTrailingSlash(this.getNodeParameter('filePath', i));
const additionalParameters = this.getNodeParameter(
'additionalParameters',
@@ -2326,7 +2327,7 @@ export class Github implements INodeType {
body.branch = (additionalParameters.branch as IDataObject).branch;
}
const filePath = this.getNodeParameter('filePath', i);
const filePath = removeTrailingSlash(this.getNodeParameter('filePath', i));
body.message = this.getNodeParameter('commitMessage', i) as string;
body.sha = await getFileSha.call(
@@ -2341,7 +2342,7 @@ export class Github implements INodeType {
} else if (operation === 'get') {
requestMethod = 'GET';
const filePath = this.getNodeParameter('filePath', i);
const filePath = removeTrailingSlash(this.getNodeParameter('filePath', i));
const additionalParameters = this.getNodeParameter(
'additionalParameters',
i,
@@ -2354,7 +2355,7 @@ export class Github implements INodeType {
endpoint = `/repos/${owner}/${repository}/contents/${encodeURIComponent(filePath)}`;
} else if (operation === 'list') {
requestMethod = 'GET';
const filePath = this.getNodeParameter('filePath', i);
const filePath = removeTrailingSlash(this.getNodeParameter('filePath', i));
endpoint = `/repos/${owner}/${repository}/contents/${encodeURIComponent(filePath)}`;
}
} else if (resource === 'issue') {