diff --git a/lib/shared/src/sourcegraph-api/graphql/url.ts b/lib/shared/src/sourcegraph-api/graphql/url.ts index 60a4f802e9ba..36a7ff7f5e18 100644 --- a/lib/shared/src/sourcegraph-api/graphql/url.ts +++ b/lib/shared/src/sourcegraph-api/graphql/url.ts @@ -1,3 +1,5 @@ +import { trimEnd } from 'lodash' + const GRAPHQL_URI = '/.api/graphql' interface BuildGraphQLUrlOptions { @@ -10,5 +12,5 @@ interface BuildGraphQLUrlOptions { export const buildGraphQLUrl = ({ request, baseUrl }: BuildGraphQLUrlOptions): string => { const nameMatch = request ? request.match(/^\s*(?:query|mutation)\s+(\w+)/) : '' const apiURL = `${GRAPHQL_URI}${nameMatch ? `?${nameMatch[1]}` : ''}` - return baseUrl ? new URL(apiURL, baseUrl).href : apiURL + return baseUrl ? new URL(trimEnd(baseUrl, '/') + apiURL).href : apiURL }