File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 11import { platform , release } from 'os'
2+ const HOST_REGEX = / ^ (? ! \w + : \/ \/ ) ( [ \w - : ] + \. ) + ( [ \w - : ] + ) (?: : ( \d + ) ) ? (? ! : ) $ /
3+
4+ export function isHost ( host ) {
5+ return HOST_REGEX . test ( host )
6+ }
27
38export function isNode ( ) {
49 return typeof process !== 'undefined' && ! process . browser
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import clonedeep from 'lodash/cloneDeep'
22import Qs from 'qs'
33import axios from 'axios'
44import contentstackRetry from './contentstack-retry'
5- const HOST_REGEX = / ^ (? ! \w + : \/ \/ ) ( [ ^ \s : ] + \. [ ^ \s : ] + ) (?: : ( \d + ) ) ? (? ! : ) $ /
5+ import { isHost } from './Util'
66
77export default function contentstackHttpClient ( options ) {
88 const defaultConfig = {
@@ -40,10 +40,10 @@ export default function contentstackHttpClient (options) {
4040
4141 const protocol = config . insecure ? 'http' : 'https'
4242 let hostname = config . defaultHostName
43- let port = 443
44- const version = 'v3'
43+ let port = config . port || 443
44+ const version = config . version || 'v3'
4545
46- if ( HOST_REGEX . test ( config . host ) ) {
46+ if ( isHost ( config . host ) ) {
4747 const parsed = config . host . split ( ':' )
4848 if ( parsed . length === 2 ) {
4949 [ hostname , port ] = parsed
You can’t perform that action at this time.
0 commit comments