File tree Expand file tree Collapse file tree 6 files changed +38
-244
lines changed
Expand file tree Collapse file tree 6 files changed +38
-244
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ fileignoreconfig:
99 ignore_detectors:
1010 - filecontent
1111 - filename: package-lock.json
12- checksum: 1475ee2c6a615f4e6f8393f4a209398aa6b827e7d036302c6fc065d5914e8292
12+ checksum: e4173c2b09c7aaee2e7c9f43a208ccb524abd123ff260d6f4636c29cf285a12f
1313 - filename: .husky/pre-commit
1414 checksum: 52a664f536cf5d1be0bea19cb6031ca6e8107b45b6314fe7d47b7fad7d800632
1515 - filename: test/sanity-check/api/user-test.js
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 44 */
55import packages from '../package.json'
66import clonedeep from 'lodash/cloneDeep'
7- import getUserAgent , { getRegionEndpoint } from './core/Util.js'
7+ import getUserAgent from './core/Util.js'
88import contentstackClient from './contentstackClient.js'
99import httpClient from './core/contentstackHTTPClient.js'
10+ import { getContentstackEndpoint } from '@contentstack/utils'
1011
1112/**
1213 * Create client instance
@@ -161,11 +162,11 @@ import httpClient from './core/contentstackHTTPClient.js'
161162 * @returns Contentstack.Client
162163 */
163164export function client ( params = { } ) {
164- let defaultHostName = getRegionEndpoint ( ' na')
165+ let defaultHostName = getContentstackEndpoint ( 'aws- na', 'contentManagement' , true )
165166
166167 if ( params . region ) {
167168 params . region = params . region . toLowerCase ( )
168- defaultHostName = getRegionEndpoint ( params . region )
169+ defaultHostName = getContentstackEndpoint ( params . region , 'contentManagement' , true )
169170 }
170171
171172 const defaultParameter = {
Original file line number Diff line number Diff line change 11import { platform , release } from 'os'
2- import regionHostMap from '../assets/regions.json'
32
43const HOST_REGEX = / ^ (? ! (?: (?: h t t p s ? | f t p ) : \/ \/ | i n t e r n a l | l o c a l h o s t | (?: (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) \. ) { 3 } (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) ) (?: [ \w - ] + \. c o n t e n t s t a c k \. (?: i o | c o m ) (?: : [ ^ \/ \s : ] + ) ? | [ \w - ] + (?: \. [ \w - ] + ) * (?: : [ ^ \/ \s : ] + ) ? ) (? ! [ \/ ? # ] ) $ / // eslint-disable-line
54
@@ -237,14 +236,3 @@ export const validateAndSanitizeConfig = (config) => {
237236 url : config . url . trim ( ) // Sanitize URL by removing whitespace
238237 }
239238}
240-
241- export const getRegionEndpoint = ( region , service = 'contentManagement' ) => {
242- const regionData = regionHostMap . regions . find ( r =>
243- r . id === region ||
244- r . alias . some ( alias => alias === region )
245- )
246- if ( ! regionData ) {
247- throw new Error ( `Invalid region '${ region } ' provided. Allowed regions are: ${ regionHostMap . regions . map ( r => r . id ) . join ( ', ' ) } ` )
248- }
249- return regionData . endpoints [ service ] ?. replace ( / ^ h t t p s ? : \/ \/ / , '' )
250- }
You can’t perform that action at this time.
0 commit comments