mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
18 lines
438 B
JavaScript
18 lines
438 B
JavaScript
// @flow
|
|
import url from 'url';
|
|
|
|
const parseGrpcUrl = (grpcUrl?: string): { url: string, enableTls: boolean } => {
|
|
const { protocol, host, href } = url.parse(grpcUrl?.toLowerCase() || '');
|
|
|
|
switch (protocol) {
|
|
case 'grpcs:':
|
|
return { url: host, enableTls: true };
|
|
case 'grpc:':
|
|
return { url: host, enableTls: false };
|
|
default:
|
|
return { url: href, enableTls: false };
|
|
}
|
|
};
|
|
|
|
export default parseGrpcUrl;
|