File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -239,12 +239,20 @@ export const validateAndSanitizeConfig = (config) => {
239239}
240240
241241export const getRegionEndpoint = ( region , service = 'contentManagement' ) => {
242+ // Validate input
243+ if ( ! region || typeof region !== 'string' ) {
244+ throw new Error ( `Invalid region '${ region } ' provided. Allowed regions are: ${ regionHostMap . regions . map ( r => r . id ) . join ( ', ' ) } ` )
245+ }
246+
247+ // Case-sensitive matching: only match exact case
242248 const regionData = regionHostMap . regions . find ( r =>
243249 r . id === region ||
244250 r . alias . some ( alias => alias === region )
245251 )
252+
246253 if ( ! regionData ) {
247254 throw new Error ( `Invalid region '${ region } ' provided. Allowed regions are: ${ regionHostMap . regions . map ( r => r . id ) . join ( ', ' ) } ` )
248255 }
256+
249257 return regionData . endpoints [ service ] ?. replace ( / ^ h t t p s ? : \/ \/ / , '' )
250258}
You can’t perform that action at this time.
0 commit comments