fix(Jira Node): Strip trailing slashes from domain URL (#32163)

Co-authored-by: RomanDavydchuk <roman.d@radency.com>
Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
Paul Bauriegel 2026-09-03 05:33:06 +00:00 committed by GitHub
parent 9244609f73
commit a69155a976
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 3 deletions

View File

@ -48,7 +48,7 @@ export class JiraSoftwareCloudApi implements ICredentialType {
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.domain}}',
baseURL: '={{$credentials.domain?.replace(/\\/+$/, "")}}',
url: '/rest/api/2/myself',
},
};

View File

@ -50,7 +50,7 @@ export class JiraSoftwareServerApi implements ICredentialType {
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.domain}}',
baseURL: '={{$credentials.domain?.replace(/\\/+$/, "")}}',
url: '/rest/api/2/myself',
},
};

View File

@ -40,7 +40,7 @@ export class JiraSoftwareServerPatApi implements ICredentialType {
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.domain}}',
baseURL: '={{$credentials.domain?.replace(/\\/+$/, "")}}',
url: '/rest/api/2/myself',
},
};

View File

@ -66,6 +66,9 @@ export async function jiraSoftwareCloudApiRequest(
credentialType = 'jiraSoftwareCloudApi';
}
// Strip trailing slashes from domain to prevent double slashes in URL construction
domain = domain.replace(/\/+$/, '');
const options: IRequestOptions = {
headers: {
Accept: 'application/json',

View File

@ -92,6 +92,20 @@ describe('Jira -> GenericFunctions', () => {
);
});
it('should remove trailing slashes from the domain before making the request', async () => {
mockExecuteFunctions.getNodeParameter.mockReturnValue('cloud');
mockExecuteFunctions.getCredentials.mockResolvedValue({
domain: 'https://example.atlassian.net///',
});
await jiraSoftwareCloudApiRequest.call(mockExecuteFunctions, '/api/2/myself', 'GET');
expect(mockExecuteFunctions.helpers.requestWithAuthentication).toHaveBeenCalledWith(
'jiraSoftwareCloudApi',
expect.objectContaining({ uri: 'https://example.atlassian.net/rest/api/2/myself' }),
);
});
it('should use jiraSoftwareCloudOAuth2Api credential for jiraVersion "cloudOAuth2" and look up cloudId', async () => {
const cloudId = 'abc123-cloud-id';
mockExecuteFunctions.getNodeParameter.mockReturnValue('cloudOAuth2');