File tree Expand file tree Collapse file tree
packages/contentstack-utilities/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,21 +147,34 @@ export function getProxyConfigForHost(host: string): ProxyConfig | undefined {
147147 return getProxyConfig ( ) ;
148148}
149149
150- export function resolveRequestHost ( config : { host ?: string } ) : string {
151- if ( config . host ) return config . host ;
150+ function regionCmaHostname ( ) : string {
152151 const cma = configStore . get ( 'region' ) ?. cma ;
153- if ( cma && typeof cma === 'string' ) {
154- if ( cma . startsWith ( 'http' ) ) {
155- try {
156- const u = new URL ( cma ) ;
157- return u . hostname || cma ;
158- } catch {
159- return cma ;
160- }
152+ if ( ! cma || typeof cma !== 'string' ) {
153+ return '' ;
154+ }
155+ if ( cma . startsWith ( 'http' ) ) {
156+ try {
157+ const u = new URL ( cma ) ;
158+ return u . hostname || cma ;
159+ } catch {
160+ return cma ;
161161 }
162- return cma ;
163162 }
164- return '' ;
163+ return cma ;
164+ }
165+
166+
167+ export function resolveRequestHost ( config : { host ?: string } ) : string {
168+ const fromRegion = regionCmaHostname ( ) ;
169+ if ( fromRegion ) {
170+ return normalizeHost ( fromRegion ) || fromRegion ;
171+ }
172+
173+ const raw = config . host ?. trim ( ) || '' ;
174+ if ( ! raw ) {
175+ return '' ;
176+ }
177+ return normalizeHost ( raw ) || raw ;
165178}
166179
167180export function clearProxyEnv ( ) : ( ) => void {
You can’t perform that action at this time.
0 commit comments