Skip to content

Commit 3967dc7

Browse files
author
naman-contentstack
committed
fix: updated the transform url logic
1 parent 5bd4313 commit 3967dc7

File tree

1 file changed

+7
-3
lines changed
  • packages/contentstack-config/src/commands/config/set

1 file changed

+7
-3
lines changed

packages/contentstack-config/src/commands/config/set/region.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
114114
composableStudioUrl = this.transformUrl(cma, 'composable-studio-api');
115115
}
116116
if (!assetManagementUrl) {
117-
// Use UI host as base and append /am/api
118-
const baseUrl = uiHost.replace(/\/$/, ''); // Remove trailing slash if present
119-
assetManagementUrl = `${baseUrl}/am/api`;
117+
assetManagementUrl = this.transformUrl(uiHost, '/am/api');
120118
}
121119
let customRegion: Region = {
122120
cda,
@@ -164,6 +162,12 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
164162
}
165163
}
166164
transformUrl(url: string, replacement: string): string {
165+
// If replacement contains '/', treat it as a path to append to the base URL
166+
if (replacement.includes('/')) {
167+
const baseUrl = url.replace(/\/$/, ''); // Remove trailing slash if present
168+
return `${baseUrl}${replacement}`;
169+
}
170+
167171
let transformedUrl = url.replace('api', replacement);
168172
if (transformedUrl.startsWith('http')) {
169173
transformedUrl = transformedUrl.split('//')[1];

0 commit comments

Comments
 (0)