import { createLogger } from '@sap-cloud-sdk/util' ; import { Destination } from './destination' ; import { Protocol } from './protocol' ; const logger = createLogger ( { package : 'connectivity' , messageContext : 'get-protocol' } ) ; param destination throws returns internal export function getProtocolOrDefault ( destination ) { const protocol = destination ?. url ?. toLowerCase ( ) ?. split ( '://' ) ; if ( ! protocol || protocol . length === 1 ) { logger . warn ( `URL of the provided destination (${ destination . url }) has no protocol specified! Assuming HTTPS.` ) ; return Protocol . HTTPS ; } const casted = Protocol . of ( protocol [ 0 ] ) ; if ( casted ) { return casted ; } throw new Error ( `Protocol of the provided destination (${ destination . url }) is not supported! Currently only HTTP and HTTPS are supported.` ) ; }