{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/tofino/pulls/comments/80111851","id":80111851,"diff_hunk":"@@ -0,0 +1,82 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,\n+ * You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+/**\n+ * This module handles opening a URL when starting Tofino with command line args, or\n+ * opening a URL when Tofino is the default browser, or when dragging a file to be loaded\n+ * via Tofino. Most of this logic is taken from Brave's implementation.\n+ * https://github.com/brave/browser-laptop/blob/master/app/cmdLine.js\n+ */\n+import electron from 'electron';\n+import { parse } from 'url';\n+import * as BW from './browser-window';\n+import * as protocols from './protocols';\n+\n+const { app } = electron;\n+const isDarwin = process.platform === 'darwin';\n+\n+// Checks an array of arguments if it can find a url\n+const getUrlFromCommandLine = argv => {\n+  if (argv) {\n+    if (argv.length === 2 && !argv[1].startsWith('-')) {\n+      const parsedUrl = parse(argv[1]);\n+      if (protocols.DEFAULT_PROTOCOLS.includes(parsedUrl.protocol)) {\n+        return argv[1];\n+      }\n+    }\n+    const index = argv.indexOf('--');\n+    if (index !== -1 && index + 1 < argv.length && !argv[index + 1].startsWith('-')) {\n+      const parsedUrl = parse(argv[index + 1]);\n+      if (protocols.DEFAULT_PROTOCOLS.includes(parsedUrl.protocol)) {\n+        return argv[index + 1];\n+      }\n+    }\n+  }\n+  return undefined;\n+};\n+\n+// For macOS, there are events like open-url instead\n+if (!isDarwin) {\n+  const openUrl = getUrlFromCommandLine(process.argv);","path":"app/main/command-line.js","position":41,"original_position":41,"commit_id":"21e947af5aff0a65f622d2ca93f010569445cbac","original_commit_id":"21e947af5aff0a65f622d2ca93f010569445cbac","user":{"login":"Mossop","id":437326,"avatar_url":"https://avatars.githubusercontent.com/u/437326?v=3","gravatar_id":"","url":"https://api.github.com/users/Mossop","html_url":"https://github.com/Mossop","followers_url":"https://api.github.com/users/Mossop/followers","following_url":"https://api.github.com/users/Mossop/following{/other_user}","gists_url":"https://api.github.com/users/Mossop/gists{/gist_id}","starred_url":"https://api.github.com/users/Mossop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mossop/subscriptions","organizations_url":"https://api.github.com/users/Mossop/orgs","repos_url":"https://api.github.com/users/Mossop/repos","events_url":"https://api.github.com/users/Mossop/events{/privacy}","received_events_url":"https://api.github.com/users/Mossop/received_events","type":"User","site_admin":false},"body":"we already use yargs for parsing the command line in the main process, can't we reuse that?","created_at":"2016-09-22T18:57:13Z","updated_at":"2016-09-22T18:59:54Z","html_url":"https://github.com/mozilla/tofino/pull/1230#discussion_r80111851","pull_request_url":"https://api.github.com/repos/mozilla/tofino/pulls/1230","_links":{"self":{"href":"https://api.github.com/repos/mozilla/tofino/pulls/comments/80111851"},"html":{"href":"https://github.com/mozilla/tofino/pull/1230#discussion_r80111851"},"pull_request":{"href":"https://api.github.com/repos/mozilla/tofino/pulls/1230"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/tofino/pulls/1230","id":86385004,"html_url":"https://github.com/mozilla/tofino/pull/1230","diff_url":"https://github.com/mozilla/tofino/pull/1230.diff","patch_url":"https://github.com/mozilla/tofino/pull/1230.patch","issue_url":"https://api.github.com/repos/mozilla/tofino/issues/1230","number":1230,"state":"open","locked":false,"title":"Open files in Tofino when it's the default browser on Windows","user":{"login":"jsantell","id":641267,"avatar_url":"https://avatars.githubusercontent.com/u/641267?v=3","gravatar_id":"","url":"https://api.github.com/users/jsantell","html_url":"https://github.com/jsantell","followers_url":"https://api.github.com/users/jsantell/followers","following_url":"https://api.github.com/users/jsantell/following{/other_user}","gists_url":"https://api.github.com/users/jsantell/gists{/gist_id}","starred_url":"https://api.github.com/users/jsantell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsantell/subscriptions","organizations_url":"https://api.github.com/users/jsantell/orgs","repos_url":"https://api.github.com/users/jsantell/repos","events_url":"https://api.github.com/users/jsantell/events{/privacy}","received_events_url":"https://api.github.com/users/jsantell/received_events","type":"User","site_admin":false},"body":"* `userAgentClient` is now attached to `electron.app` and we can use that as a global to determine state of the application startup, and simplify interfaces like in browser-window\r\n* Now handles opening via command line on OSX/Windows(?) via `open -a Tofino https://mozilla.org` **needs confirmed in Windows**\r\n* Windows should now be able to open links when it's the default if it's closed or open already -- **needs confirmed**\r\n\r\n** To confirm on Windows **\r\n\r\n- [ ] Handles `open -a Tofino https://mozilla.org` or whatever the CLI equiv on Windows is\r\n- [ ] When set as default browser, should open a tab for a link while open\r\n- [ ] When set as default browser, should open a tab for a link while closed\r\n- [ ] When opening an incoming link, it should not create a new instance and open it in an existing window/create a new window\r\n\r\n\r\nThis does **not** ask Windows users if they want to set Tofino as a default browser, due to issues with Windows 10 defaults.","created_at":"2016-09-22T17:58:27Z","updated_at":"2016-09-22T18:59:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"408baf3d4fe432d768b416be332142cddaed424f","assignee":{"login":"Mossop","id":437326,"avatar_url":"https://avatars.githubusercontent.com/u/437326?v=3","gravatar_id":"","url":"https://api.github.com/users/Mossop","html_url":"https://github.com/Mossop","followers_url":"https://api.github.com/users/Mossop/followers","following_url":"https://api.github.com/users/Mossop/following{/other_user}","gists_url":"https://api.github.com/users/Mossop/gists{/gist_id}","starred_url":"https://api.github.com/users/Mossop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mossop/subscriptions","organizations_url":"https://api.github.com/users/Mossop/orgs","repos_url":"https://api.github.com/users/Mossop/repos","events_url":"https://api.github.com/users/Mossop/events{/privacy}","received_events_url":"https://api.github.com/users/Mossop/received_events","type":"User","site_admin":false},"assignees":[{"login":"Mossop","id":437326,"avatar_url":"https://avatars.githubusercontent.com/u/437326?v=3","gravatar_id":"","url":"https://api.github.com/users/Mossop","html_url":"https://github.com/Mossop","followers_url":"https://api.github.com/users/Mossop/followers","following_url":"https://api.github.com/users/Mossop/following{/other_user}","gists_url":"https://api.github.com/users/Mossop/gists{/gist_id}","starred_url":"https://api.github.com/users/Mossop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mossop/subscriptions","organizations_url":"https://api.github.com/users/Mossop/orgs","repos_url":"https://api.github.com/users/Mossop/repos","events_url":"https://api.github.com/users/Mossop/events{/privacy}","received_events_url":"https://api.github.com/users/Mossop/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/tofino/pulls/1230/commits","review_comments_url":"https://api.github.com/repos/mozilla/tofino/pulls/1230/comments","review_comment_url":"https://api.github.com/repos/mozilla/tofino/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/tofino/issues/1230/comments","statuses_url":"https://api.github.com/repos/mozilla/tofino/statuses/21e947af5aff0a65f622d2ca93f010569445cbac","head":{"label":"jsantell:1210","ref":"1210","sha":"21e947af5aff0a65f622d2ca93f010569445cbac","user":{"login":"jsantell","id":641267,"avatar_url":"https://avatars.githubusercontent.com/u/641267?v=3","gravatar_id":"","url":"https://api.github.com/users/jsantell","html_url":"https://github.com/jsantell","followers_url":"https://api.github.com/users/jsantell/followers","following_url":"https://api.github.com/users/jsantell/following{/other_user}","gists_url":"https://api.github.com/users/jsantell/gists{/gist_id}","starred_url":"https://api.github.com/users/jsantell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsantell/subscriptions","organizations_url":"https://api.github.com/users/jsantell/orgs","repos_url":"https://api.github.com/users/jsantell/repos","events_url":"https://api.github.com/users/jsantell/events{/privacy}","received_events_url":"https://api.github.com/users/jsantell/received_events","type":"User","site_admin":false},"repo":{"id":55798745,"name":"tofino","full_name":"jsantell/tofino","owner":{"login":"jsantell","id":641267,"avatar_url":"https://avatars.githubusercontent.com/u/641267?v=3","gravatar_id":"","url":"https://api.github.com/users/jsantell","html_url":"https://github.com/jsantell","followers_url":"https://api.github.com/users/jsantell/followers","following_url":"https://api.github.com/users/jsantell/following{/other_user}","gists_url":"https://api.github.com/users/jsantell/gists{/gist_id}","starred_url":"https://api.github.com/users/jsantell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsantell/subscriptions","organizations_url":"https://api.github.com/users/jsantell/orgs","repos_url":"https://api.github.com/users/jsantell/repos","events_url":"https://api.github.com/users/jsantell/events{/privacy}","received_events_url":"https://api.github.com/users/jsantell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jsantell/tofino","description":"Project Tofino is a browser interaction experiment.","fork":true,"url":"https://api.github.com/repos/jsantell/tofino","forks_url":"https://api.github.com/repos/jsantell/tofino/forks","keys_url":"https://api.github.com/repos/jsantell/tofino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jsantell/tofino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jsantell/tofino/teams","hooks_url":"https://api.github.com/repos/jsantell/tofino/hooks","issue_events_url":"https://api.github.com/repos/jsantell/tofino/issues/events{/number}","events_url":"https://api.github.com/repos/jsantell/tofino/events","assignees_url":"https://api.github.com/repos/jsantell/tofino/assignees{/user}","branches_url":"https://api.github.com/repos/jsantell/tofino/branches{/branch}","tags_url":"https://api.github.com/repos/jsantell/tofino/tags","blobs_url":"https://api.github.com/repos/jsantell/tofino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jsantell/tofino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jsantell/tofino/git/refs{/sha}","trees_url":"https://api.github.com/repos/jsantell/tofino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jsantell/tofino/statuses/{sha}","languages_url":"https://api.github.com/repos/jsantell/tofino/languages","stargazers_url":"https://api.github.com/repos/jsantell/tofino/stargazers","contributors_url":"https://api.github.com/repos/jsantell/tofino/contributors","subscribers_url":"https://api.github.com/repos/jsantell/tofino/subscribers","subscription_url":"https://api.github.com/repos/jsantell/tofino/subscription","commits_url":"https://api.github.com/repos/jsantell/tofino/commits{/sha}","git_commits_url":"https://api.github.com/repos/jsantell/tofino/git/commits{/sha}","comments_url":"https://api.github.com/repos/jsantell/tofino/comments{/number}","issue_comment_url":"https://api.github.com/repos/jsantell/tofino/issues/comments{/number}","contents_url":"https://api.github.com/repos/jsantell/tofino/contents/{+path}","compare_url":"https://api.github.com/repos/jsantell/tofino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jsantell/tofino/merges","archive_url":"https://api.github.com/repos/jsantell/tofino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jsantell/tofino/downloads","issues_url":"https://api.github.com/repos/jsantell/tofino/issues{/number}","pulls_url":"https://api.github.com/repos/jsantell/tofino/pulls{/number}","milestones_url":"https://api.github.com/repos/jsantell/tofino/milestones{/number}","notifications_url":"https://api.github.com/repos/jsantell/tofino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jsantell/tofino/labels{/name}","releases_url":"https://api.github.com/repos/jsantell/tofino/releases{/id}","deployments_url":"https://api.github.com/repos/jsantell/tofino/deployments","created_at":"2016-04-08T17:52:20Z","updated_at":"2016-06-09T18:34:35Z","pushed_at":"2016-09-22T18:48:48Z","git_url":"git://github.com/jsantell/tofino.git","ssh_url":"git@github.com:jsantell/tofino.git","clone_url":"https://github.com/jsantell/tofino.git","svn_url":"https://github.com/jsantell/tofino","homepage":"https://medium.com/project-tofino","size":4442,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"810959b94be3fb24399ce18171a65f2a8dd2a229","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":55401807,"name":"tofino","full_name":"mozilla/tofino","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/tofino","description":"Project Tofino is a browser interaction experiment.","fork":false,"url":"https://api.github.com/repos/mozilla/tofino","forks_url":"https://api.github.com/repos/mozilla/tofino/forks","keys_url":"https://api.github.com/repos/mozilla/tofino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/tofino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/tofino/teams","hooks_url":"https://api.github.com/repos/mozilla/tofino/hooks","issue_events_url":"https://api.github.com/repos/mozilla/tofino/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/tofino/events","assignees_url":"https://api.github.com/repos/mozilla/tofino/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/tofino/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/tofino/tags","blobs_url":"https://api.github.com/repos/mozilla/tofino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/tofino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/tofino/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/tofino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/tofino/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/tofino/languages","stargazers_url":"https://api.github.com/repos/mozilla/tofino/stargazers","contributors_url":"https://api.github.com/repos/mozilla/tofino/contributors","subscribers_url":"https://api.github.com/repos/mozilla/tofino/subscribers","subscription_url":"https://api.github.com/repos/mozilla/tofino/subscription","commits_url":"https://api.github.com/repos/mozilla/tofino/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/tofino/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/tofino/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/tofino/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/tofino/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/tofino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/tofino/merges","archive_url":"https://api.github.com/repos/mozilla/tofino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/tofino/downloads","issues_url":"https://api.github.com/repos/mozilla/tofino/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/tofino/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/tofino/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/tofino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/tofino/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/tofino/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/tofino/deployments","created_at":"2016-04-04T10:13:26Z","updated_at":"2016-09-22T18:52:59Z","pushed_at":"2016-09-22T18:49:08Z","git_url":"git://github.com/mozilla/tofino.git","ssh_url":"git@github.com:mozilla/tofino.git","clone_url":"https://github.com/mozilla/tofino.git","svn_url":"https://github.com/mozilla/tofino","homepage":"https://mozilla.github.io/tofino","size":6017,"stargazers_count":521,"watchers_count":521,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":57,"mirror_url":null,"open_issues_count":115,"forks":57,"open_issues":115,"watchers":521,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/tofino/pulls/1230"},"html":{"href":"https://github.com/mozilla/tofino/pull/1230"},"issue":{"href":"https://api.github.com/repos/mozilla/tofino/issues/1230"},"comments":{"href":"https://api.github.com/repos/mozilla/tofino/issues/1230/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/tofino/pulls/1230/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/tofino/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/tofino/pulls/1230/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/tofino/statuses/21e947af5aff0a65f622d2ca93f010569445cbac"}}}}
{"actor":{"display_login":"Mossop"}}