Skip to content

Commit

Permalink
Fix context files urls (#4955)
Browse files Browse the repository at this point in the history
A recent change brok the urls. This PR reverts the original behaviour.

The recent change:
#4706 (comment)
Slack thread:
https://sourcegraph.slack.com/archives/C05AGQYD528/p1721382757890889

## Test plan
- chat context file items looks properly for remote files
  • Loading branch information
mkondratek authored Jul 20, 2024
1 parent 33745a9 commit 46b3f10
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/shared/src/sourcegraph-api/graphql/url.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { trimEnd } from 'lodash'

const GRAPHQL_URI = '/.api/graphql'

interface BuildGraphQLUrlOptions {
Expand All @@ -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
}

0 comments on commit 46b3f10

Please sign in to comment.