diff --git a/packages/insomnia/src/main/ipc/grpc.ts b/packages/insomnia/src/main/ipc/grpc.ts index 0edadbceff7..ddcbcb6e85f 100644 --- a/packages/insomnia/src/main/ipc/grpc.ts +++ b/packages/insomnia/src/main/ipc/grpc.ts @@ -389,7 +389,7 @@ export const start = ( } const methodType = getMethodType(method); // Create client - const { url } = parseGrpcUrl(request.url); + const { url, path } = parseGrpcUrl(request.url); if (!url) { event.reply('grpc.error', request._id, new Error('URL not specified')); @@ -405,10 +405,11 @@ export const start = ( try { const messageBody = JSON.parse(request.body.text || ''); + const requestPath = path + method.path; switch (methodType) { case 'unary': const unaryCall = client.makeUnaryRequest( - method.path, + requestPath, method.requestSerialize, method.responseDeserialize, messageBody, @@ -420,7 +421,7 @@ export const start = ( break; case 'client': const clientCall = client.makeClientStreamRequest( - method.path, + requestPath, method.requestSerialize, method.responseDeserialize, filterDisabledMetaData(request.metadata), @@ -430,7 +431,7 @@ export const start = ( break; case 'server': const serverCall = client.makeServerStreamRequest( - method.path, + requestPath, method.requestSerialize, method.responseDeserialize, messageBody, @@ -441,7 +442,7 @@ export const start = ( break; case 'bidi': const bidiCall = client.makeBidiStreamRequest( - method.path, + requestPath, method.requestSerialize, method.responseDeserialize, filterDisabledMetaData(request.metadata)); diff --git a/packages/insomnia/src/network/grpc/parse-grpc-url.ts b/packages/insomnia/src/network/grpc/parse-grpc-url.ts index 67765e5b50f..c40c3156c15 100644 --- a/packages/insomnia/src/network/grpc/parse-grpc-url.ts +++ b/packages/insomnia/src/network/grpc/parse-grpc-url.ts @@ -1,13 +1,18 @@ -export const parseGrpcUrl = (grpcUrl: string): { url: string; enableTls: boolean } => { +export const parseGrpcUrl = (grpcUrl: string): { url: string; enableTls: boolean; path: string } => { if (!grpcUrl) { - return { url: '', enableTls: false }; + return { url: '', enableTls: false, path: '' }; } - const lower = grpcUrl.toLowerCase(); - if (lower.startsWith('grpc://')) { - return { url: lower.slice(7), enableTls: false }; + const url = new URL(grpcUrl); + const result = { + url: url.host, + enableTls: false, + path: url.pathname, + }; + if (url.protocol === 'grpcs:') { + result.enableTls = true; } - if (lower.startsWith('grpcs://')) { - return { url: lower.slice(8), enableTls: true }; + if (result.path === '/') { + result.path = ''; } - return { url: lower, enableTls: false }; + return result; }; diff --git a/packages/insomnia/src/ui/components/dropdowns/grpc-method-dropdown/grpc-method-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/grpc-method-dropdown/grpc-method-dropdown.tsx index baa7ef367cc..309c4b0cbcc 100644 --- a/packages/insomnia/src/ui/components/dropdowns/grpc-method-dropdown/grpc-method-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/grpc-method-dropdown/grpc-method-dropdown.tsx @@ -70,7 +70,6 @@ export const GrpcMethodDropdown: FunctionComponent = ({ })); const selectedPath = selectedMethod?.fullPath; - console.log(methods, disabled); return (