mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 21:49:36 +02:00
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:
parent
9244609f73
commit
a69155a976
|
|
@ -48,7 +48,7 @@ export class JiraSoftwareCloudApi implements ICredentialType {
|
|||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '={{$credentials?.domain}}',
|
||||
baseURL: '={{$credentials.domain?.replace(/\\/+$/, "")}}',
|
||||
url: '/rest/api/2/myself',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export class JiraSoftwareServerApi implements ICredentialType {
|
|||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '={{$credentials?.domain}}',
|
||||
baseURL: '={{$credentials.domain?.replace(/\\/+$/, "")}}',
|
||||
url: '/rest/api/2/myself',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export class JiraSoftwareServerPatApi implements ICredentialType {
|
|||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '={{$credentials?.domain}}',
|
||||
baseURL: '={{$credentials.domain?.replace(/\\/+$/, "")}}',
|
||||
url: '/rest/api/2/myself',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user