{"action":"created","comment":{"url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/comments/232404757","pull_request_review_id":173605161,"id":232404757,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjQwNDc1Nw==","diff_hunk":"@@ -0,0 +1,63 @@\n+import * as sourcegraph from 'sourcegraph'\n+\n+/**\n+ * @param textDocumentUri The Sourcegraph text document URI, e.g. `git://github.com/sourcegraph/extensions-client-common?80389224bd48e1e696d5fa11b3ec6fba341c695b#src/schema/graphqlschema.ts`\n+ * @returns The root URI for the server, e.g. `https://accesstoken@sourcegraph.com/.api/github.com/sourcegraph/extensions-client-common@80389224bd48e1e696d5fa11b3ec6fba341c695b/-/raw/`. Always has a trailing slash.\n+ */\n+export function resolveServerRootUri(textDocumentUri: URL): URL {\n+    const rootUri = new URL(sourcegraph.internal.sourcegraphURL.toString())\n+    // rootUri.username = accessToken\n+    rootUri.pathname =\n+        '/.api/' + textDocumentUri.host + textDocumentUri.pathname + '@' + textDocumentUri.search.substr(1) + '/-/raw/'\n+    return rootUri\n+}\n+\n+/**\n+ * @param textDocumentUri The Sourcegraph text document URI like git://github.com/sourcegraph/extensions-client-common?80389224bd48e1e696d5fa11b3ec6fba341c695b#src/schema/graphqlschema.ts\n+ * @returns The text document URI for the server, e.g. https://accesstoken@sourcegraph.com/.api/github.com/sourcegraph/extensions-client-common@80389224bd48e1e696d5fa11b3ec6fba341c695b/-/raw/src/schema/graphqlschema.ts","path":"extension/src/uris.ts","position":17,"original_position":17,"commit_id":"ce5004a0d3894fddecfd7a6706ab9415665379f4","original_commit_id":"ce5004a0d3894fddecfd7a6706ab9415665379f4","user":{"login":"felixfbecker","id":10532611,"node_id":"MDQ6VXNlcjEwNTMyNjEx","avatar_url":"https://avatars0.githubusercontent.com/u/10532611?v=4","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"body":"@beyang's complaint was supporting this for UI routes, but I am using `/.api` here, so I would expect this to work. I explained why on Slack too: https://sourcegraph.slack.com/archives/CCLF4R6EM/p1541724525147200?thread_ts=1541720380.139600&cid=CCLF4R6EM\r\n\r\nIf I pass a root URI to the language server like `https://sourcegraph.com/.api/github.com/sourcegraph/repo@rev/-/raw/?token=abc123` and then the language server wants to fetch file `test.ts`, it will resolve the URL for `test.ts` relatively to the root URI. The query parameter gets lost in that process because it is tied to the path, not to the host. The userinfo part of the URL is part of the authority (tied to the host). \r\n\r\nIllustrative example:\r\n```ts\r\nnew URL('test.ts', 'https://test.com?token=abc').toString() === 'https://test.com/test.ts'\r\nnew URL('test.ts', 'https://abc@test.com').toString() === 'https://abc@test.com/test.ts'\r\n```\r\n\r\nSupport for tokens in the authinfo part is a strict requirement for the whole plan to work.","created_at":"2018-11-09T21:52:53Z","updated_at":"2018-11-09T21:52:54Z","html_url":"https://github.com/sourcegraph/lang-typescript/pull/7#discussion_r232404757","pull_request_url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/comments/232404757"},"html":{"href":"https://github.com/sourcegraph/lang-typescript/pull/7#discussion_r232404757"},"pull_request":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7"}},"in_reply_to_id":232396575},"pull_request":{"url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7","id":229562717,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5NTYyNzE3","html_url":"https://github.com/sourcegraph/lang-typescript/pull/7","diff_url":"https://github.com/sourcegraph/lang-typescript/pull/7.diff","patch_url":"https://github.com/sourcegraph/lang-typescript/pull/7.patch","issue_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/7","number":7,"state":"open","locked":false,"title":"Use Sourcegraph raw API with access tokens instead of GitHub","user":{"login":"felixfbecker","id":10532611,"node_id":"MDQ6VXNlcjEwNTMyNjEx","avatar_url":"https://avatars0.githubusercontent.com/u/10532611?v=4","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"body":"Depends on https://github.com/sourcegraph/sourcegraph/pull/800","created_at":"2018-11-09T01:35:13Z","updated_at":"2018-11-09T21:52:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"344517d45153ad12566631d6ad335e6c94c959df","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7/commits","review_comments_url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7/comments","review_comment_url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/7/comments","statuses_url":"https://api.github.com/repos/sourcegraph/lang-typescript/statuses/ce5004a0d3894fddecfd7a6706ab9415665379f4","head":{"label":"sourcegraph:sg-raw","ref":"sg-raw","sha":"ce5004a0d3894fddecfd7a6706ab9415665379f4","user":{"login":"sourcegraph","id":3979584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5Nzk1ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/3979584?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"repo":{"id":155401150,"node_id":"MDEwOlJlcG9zaXRvcnkxNTU0MDExNTA=","name":"lang-typescript","full_name":"sourcegraph/lang-typescript","private":false,"owner":{"login":"sourcegraph","id":3979584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5Nzk1ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/3979584?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/sourcegraph/lang-typescript","description":"Provides code intelligence for TypeScript","fork":false,"url":"https://api.github.com/repos/sourcegraph/lang-typescript","forks_url":"https://api.github.com/repos/sourcegraph/lang-typescript/forks","keys_url":"https://api.github.com/repos/sourcegraph/lang-typescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcegraph/lang-typescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcegraph/lang-typescript/teams","hooks_url":"https://api.github.com/repos/sourcegraph/lang-typescript/hooks","issue_events_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/events{/number}","events_url":"https://api.github.com/repos/sourcegraph/lang-typescript/events","assignees_url":"https://api.github.com/repos/sourcegraph/lang-typescript/assignees{/user}","branches_url":"https://api.github.com/repos/sourcegraph/lang-typescript/branches{/branch}","tags_url":"https://api.github.com/repos/sourcegraph/lang-typescript/tags","blobs_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcegraph/lang-typescript/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcegraph/lang-typescript/languages","stargazers_url":"https://api.github.com/repos/sourcegraph/lang-typescript/stargazers","contributors_url":"https://api.github.com/repos/sourcegraph/lang-typescript/contributors","subscribers_url":"https://api.github.com/repos/sourcegraph/lang-typescript/subscribers","subscription_url":"https://api.github.com/repos/sourcegraph/lang-typescript/subscription","commits_url":"https://api.github.com/repos/sourcegraph/lang-typescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcegraph/lang-typescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcegraph/lang-typescript/contents/{+path}","compare_url":"https://api.github.com/repos/sourcegraph/lang-typescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcegraph/lang-typescript/merges","archive_url":"https://api.github.com/repos/sourcegraph/lang-typescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcegraph/lang-typescript/downloads","issues_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues{/number}","pulls_url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcegraph/lang-typescript/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcegraph/lang-typescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcegraph/lang-typescript/labels{/name}","releases_url":"https://api.github.com/repos/sourcegraph/lang-typescript/releases{/id}","deployments_url":"https://api.github.com/repos/sourcegraph/lang-typescript/deployments","created_at":"2018-10-30T14:39:02Z","updated_at":"2018-11-09T19:22:12Z","pushed_at":"2018-11-09T21:13:43Z","git_url":"git://github.com/sourcegraph/lang-typescript.git","ssh_url":"git@github.com:sourcegraph/lang-typescript.git","clone_url":"https://github.com/sourcegraph/lang-typescript.git","svn_url":"https://github.com/sourcegraph/lang-typescript","homepage":null,"size":1251,"stargazers_count":1,"watchers_count":1,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"base":{"label":"sourcegraph:master","ref":"master","sha":"8456bed0730557aea672ec727cb023979e489496","user":{"login":"sourcegraph","id":3979584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5Nzk1ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/3979584?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"repo":{"id":155401150,"node_id":"MDEwOlJlcG9zaXRvcnkxNTU0MDExNTA=","name":"lang-typescript","full_name":"sourcegraph/lang-typescript","private":false,"owner":{"login":"sourcegraph","id":3979584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5Nzk1ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/3979584?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/sourcegraph/lang-typescript","description":"Provides code intelligence for TypeScript","fork":false,"url":"https://api.github.com/repos/sourcegraph/lang-typescript","forks_url":"https://api.github.com/repos/sourcegraph/lang-typescript/forks","keys_url":"https://api.github.com/repos/sourcegraph/lang-typescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcegraph/lang-typescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcegraph/lang-typescript/teams","hooks_url":"https://api.github.com/repos/sourcegraph/lang-typescript/hooks","issue_events_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/events{/number}","events_url":"https://api.github.com/repos/sourcegraph/lang-typescript/events","assignees_url":"https://api.github.com/repos/sourcegraph/lang-typescript/assignees{/user}","branches_url":"https://api.github.com/repos/sourcegraph/lang-typescript/branches{/branch}","tags_url":"https://api.github.com/repos/sourcegraph/lang-typescript/tags","blobs_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcegraph/lang-typescript/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcegraph/lang-typescript/languages","stargazers_url":"https://api.github.com/repos/sourcegraph/lang-typescript/stargazers","contributors_url":"https://api.github.com/repos/sourcegraph/lang-typescript/contributors","subscribers_url":"https://api.github.com/repos/sourcegraph/lang-typescript/subscribers","subscription_url":"https://api.github.com/repos/sourcegraph/lang-typescript/subscription","commits_url":"https://api.github.com/repos/sourcegraph/lang-typescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcegraph/lang-typescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcegraph/lang-typescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcegraph/lang-typescript/contents/{+path}","compare_url":"https://api.github.com/repos/sourcegraph/lang-typescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcegraph/lang-typescript/merges","archive_url":"https://api.github.com/repos/sourcegraph/lang-typescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcegraph/lang-typescript/downloads","issues_url":"https://api.github.com/repos/sourcegraph/lang-typescript/issues{/number}","pulls_url":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcegraph/lang-typescript/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcegraph/lang-typescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcegraph/lang-typescript/labels{/name}","releases_url":"https://api.github.com/repos/sourcegraph/lang-typescript/releases{/id}","deployments_url":"https://api.github.com/repos/sourcegraph/lang-typescript/deployments","created_at":"2018-10-30T14:39:02Z","updated_at":"2018-11-09T19:22:12Z","pushed_at":"2018-11-09T21:13:43Z","git_url":"git://github.com/sourcegraph/lang-typescript.git","ssh_url":"git@github.com:sourcegraph/lang-typescript.git","clone_url":"https://github.com/sourcegraph/lang-typescript.git","svn_url":"https://github.com/sourcegraph/lang-typescript","homepage":null,"size":1251,"stargazers_count":1,"watchers_count":1,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7"},"html":{"href":"https://github.com/sourcegraph/lang-typescript/pull/7"},"issue":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/7"},"comments":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/sourcegraph/lang-typescript/statuses/ce5004a0d3894fddecfd7a6706ab9415665379f4"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"felixfbecker"}}