Skip to content
Merged
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
14 changes: 9 additions & 5 deletions src/pipedrive-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
response.status,
endpoint
);
(error as any).statusCode = response.status;

Check warning on line 263 in src/pipedrive-client.ts

View workflow job for this annotation

GitHub Actions / Test on Node 22

Unexpected any. Specify a different type

Check warning on line 263 in src/pipedrive-client.ts

View workflow job for this annotation

GitHub Actions / Test on Node 24

Unexpected any. Specify a different type
throw error;
}

Expand Down Expand Up @@ -303,11 +303,15 @@
}

private resolveUrl(endpoint: string): string {
// v2 endpoints come as "/api/v2/..." — use bare host.
// v1 endpoints come as "/deals", "/persons", etc. — prepend "/v1".
return endpoint.startsWith('/api/v2/')
? `https://api.pipedrive.com${endpoint}`
: `${this.baseUrl}${endpoint}`;
// v1 endpoints come as "/deals", "/persons", etc. and live under baseUrl (".../v1").
// v2 endpoints come as "/api/v2/..." and hang off the bare host — derive it from
// baseUrl (strip the trailing "/v1") so both share the same host even if baseUrl
// is ever pointed at a company-specific domain.
if (endpoint.startsWith('/api/v2/')) {
const host = this.baseUrl.replace(/\/v1\/?$/, '');
return `${host}${endpoint}`;
}
return `${this.baseUrl}${endpoint}`;
}

private invalidateCachePattern(endpoint: string): void {
Expand Down
Loading