diff --git a/package-lock.json b/package-lock.json index 699ce356d3e..885a2f7c23f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13059,7 +13059,7 @@ }, "node_modules/grpc-reflection-js": { "version": "0.3.0", - "resolved": "git+ssh://git@github.com/ryanexus/grpc-reflection-js.git#1d769dc539635cac4b46ae7aab57ff4c4b935e90", + "resolved": "git+ssh://git@github.com/Kong/grpc-reflection-js.git#f806b5a0dc2092b7a6fb54dfb66c38fb58231774", "license": "MIT", "dependencies": { "@types/google-protobuf": "^3.7.2", @@ -23095,7 +23095,7 @@ "fastq": "^1.17.1", "graphql": "^16.8.1", "graphql-ws": "^5.16.0", - "grpc-reflection-js": "ryanexus/grpc-reflection-js#path-prefix", + "grpc-reflection-js": "Kong/grpc-reflection-js#master", "hawk": "9.0.2", "hkdf": "^0.0.2", "hosted-git-info": "5.2.1", diff --git a/packages/insomnia/package.json b/packages/insomnia/package.json index ed320c71156..d83a5c6b7f9 100644 --- a/packages/insomnia/package.json +++ b/packages/insomnia/package.json @@ -57,7 +57,7 @@ "fastq": "^1.17.1", "graphql": "^16.8.1", "graphql-ws": "^5.16.0", - "grpc-reflection-js": "ryanexus/grpc-reflection-js#path-prefix", + "grpc-reflection-js": "Kong/grpc-reflection-js#master", "hawk": "9.0.2", "hkdf": "^0.0.2", "hosted-git-info": "5.2.1", diff --git a/packages/insomnia/src/network/grpc/parse-grpc-url.ts b/packages/insomnia/src/network/grpc/parse-grpc-url.ts index b4aef0df5b2..00ef812cdd2 100644 --- a/packages/insomnia/src/network/grpc/parse-grpc-url.ts +++ b/packages/insomnia/src/network/grpc/parse-grpc-url.ts @@ -2,28 +2,12 @@ export const parseGrpcUrl = (grpcUrl: string): { url: string; enableTls: boolean if (!grpcUrl) { return { url: '', enableTls: false, path: '' }; } - const lcUrl = grpcUrl.toLowerCase(); - let url = { - protocol: 'grpc:', - hostname: lcUrl, - pathname: '', - port: undefined, - } as unknown as URL; - if (lcUrl.includes('://')) { - try { - url = new URL(grpcUrl.toLowerCase()); - } catch (e) { } - } - const result = { - url: `${url.hostname}` + (url.port ? `:${url.port}` : ''), - enableTls: false, - path: url.pathname, + const url = new URL((grpcUrl.includes('://') ? '' : 'grpc://') + grpcUrl.toLowerCase()); + return { + url: url.host, + enableTls: url.protocol === 'grpcs:', + // remove trailing slashes from pathname; the full request + // path is a concatenation of this parsed path + method path + path: url.pathname.endsWith('/') ? url.pathname.slice(0, -1) : url.pathname, }; - if (url.protocol.toLowerCase() === 'grpcs:') { - result.enableTls = true; - } - if (result.path === '/') { - result.path = ''; - } - return result; };