Skip to content

Commit e74215e

Browse files
refactor: refactored getEndpoint() to check if baseURL ends with /b
1 parent 36f4148 commit e74215e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

packages/core/src/plugins/SegmentDestination.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ export class SegmentDestination extends DestinationPlugin {
9393
const hasProxy = !!(config?.proxy ?? '');
9494
const useSegmentEndpoints = Boolean(config?.useSegmentEndpoints);
9595
// Determine the base URL based on config or this.apiHost, defaulting to defaultApiHost
96-
let baseURL = config?.proxy ?? this.apiHost ?? defaultApiHost;
97-
98-
// If baseURL is null or undefined, fallback to defaultApiHost
99-
if (!baseURL) {
100-
baseURL = defaultApiHost;
101-
}
96+
const baseURL = config?.proxy ?? this.apiHost ?? defaultApiHost;
10297

10398
let endpoint = '';
10499

105100
if (hasProxy) {
106101
endpoint = useSegmentEndpoints ? '/b' : '';
107102
} else {
108-
endpoint = baseURL === defaultApiHost ? '' : '/b';
103+
// Check if baseURL ends with '/b', if so, do not append '/b'
104+
if (baseURL.endsWith('/b')) {
105+
endpoint = ''; // Don't append '/b'
106+
} else {
107+
endpoint = '/b'; // Append '/b'
108+
}
109109
}
110110

111111
return getURL(baseURL, endpoint);

0 commit comments

Comments
 (0)