{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/comments/175155437","pull_request_review_id":104645820,"id":175155437,"diff_hunk":"@@ -7,29 +7,56 @@ export function parseFilterString(filter) {\n   if (!filter) {\n     return [];\n   }\n-  return filter.split(/\\s+/).map((i) => i.toLocaleLowerCase());\n+  return filter.split(/\\s+/);\n+}\n+\n+function tryMakeURL(string, defaultProtocol = null) {\n+  let url = null;\n+  try {\n+    url = new URL(string);\n+  } catch (e) {\n+    if (defaultProtocol) {\n+      try {\n+        url = new URL(defaultProtocol + \"//\" + string);\n+      } catch (e) {}\n+    }\n+  }\n+  return {url, string};\n }\n \n function match(filterElement, value) {\n-  return value.includes(filterElement);\n+  return value.toLocaleLowerCase().includes(filterElement.toLocaleLowerCase());\n+}\n+\n+function matchURL(filterElement, value) {\n+  // If the user is in the middle of typing a URL or entered something not\n+  // URL-like in the origin field, just to a string comparison. This is safe for\n+  // strictly matching auto-filled URLs since they're always full hosts with\n+  // protocol (and possibly port).\n+  if (!filterElement.url || !value.url) {\n+    return match(filterElement.string, value.string);\n+  }\n+  return (filterElement.url.protocol === value.url.protocol &&\n+          filterElement.url.host === value.url.host);","path":"src/webextension/list/filter.js","position":36,"original_position":36,"commit_id":"5ec79fd58e4c43de89e0b172dc3759ccba6de7ac","original_commit_id":"5ec79fd58e4c43de89e0b172dc3759ccba6de7ac","user":{"login":"jimporter","id":826865,"avatar_url":"https://avatars0.githubusercontent.com/u/826865?v=4","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"body":"`URL.host` includes the port if it's not the default port for that protocol. So for `https://www.google.com`, `URL.host` is `www.google.com`, but for `https://www.google.com:8000`, `URL.host` is `www.google.com:8000`. I plan to make this a lot more explicit when I build some common functions to use here (i.e. I'll write documentation).","created_at":"2018-03-16T17:04:31Z","updated_at":"2018-03-16T17:04:31Z","html_url":"https://github.com/mozilla-lockbox/lockbox-extension/pull/660#discussion_r175155437","pull_request_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/comments/175155437"},"html":{"href":"https://github.com/mozilla-lockbox/lockbox-extension/pull/660#discussion_r175155437"},"pull_request":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660"}},"in_reply_to_id":175074935},"pull_request":{"url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660","id":175062146,"html_url":"https://github.com/mozilla-lockbox/lockbox-extension/pull/660","diff_url":"https://github.com/mozilla-lockbox/lockbox-extension/pull/660.diff","patch_url":"https://github.com/mozilla-lockbox/lockbox-extension/pull/660.patch","issue_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues/660","number":660,"state":"open","locked":false,"title":"[WIP] Parse URLs when filtering","user":{"login":"jimporter","id":826865,"avatar_url":"https://avatars0.githubusercontent.com/u/826865?v=4","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"body":"This is still very WIP, but it should give an idea of how I plan to pass the data around. The general idea is that when the popup opens, we fill in the protocol, host, and port (if the port is default, it's implicitly defined by the protocol), which then gets passed to the filter code.\r\n\r\nThe filter code rebuilds a URL object and tries to match it to URL objects for the origins of each item. Origins are allowed to omit their protocol, in which case we treat them as HTTPS. If the search query omits *its* protocol (this will only happen when the user is typing in the filter themselves), we just do a string comparison. This way, you only have to type part of a URL (e.g. \"goo\" for \"https://www.google.com\") to filter the results down when you're searching manually.\r\n\r\nUp next, I plan to make the matching on valid URLs work closer to our plan.","created_at":"2018-03-14T19:31:23Z","updated_at":"2018-03-16T17:04:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83a50cd347e97a675136b72ed62887e8de70bce2","assignee":{"login":"jimporter","id":826865,"avatar_url":"https://avatars0.githubusercontent.com/u/826865?v=4","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"assignees":[{"login":"jimporter","id":826865,"avatar_url":"https://avatars0.githubusercontent.com/u/826865?v=4","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":710419045,"url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/labels/in%20progress","name":"in progress","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660/commits","review_comments_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660/comments","review_comment_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues/660/comments","statuses_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/statuses/5ec79fd58e4c43de89e0b172dc3759ccba6de7ac","head":{"label":"jimporter:url-parser","ref":"url-parser","sha":"5ec79fd58e4c43de89e0b172dc3759ccba6de7ac","user":{"login":"jimporter","id":826865,"avatar_url":"https://avatars0.githubusercontent.com/u/826865?v=4","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"repo":{"id":96815440,"name":"lockbox-extension","full_name":"jimporter/lockbox-extension","owner":{"login":"jimporter","id":826865,"avatar_url":"https://avatars0.githubusercontent.com/u/826865?v=4","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jimporter/lockbox-extension","description":"Lockbox extension for Firefox","fork":true,"url":"https://api.github.com/repos/jimporter/lockbox-extension","forks_url":"https://api.github.com/repos/jimporter/lockbox-extension/forks","keys_url":"https://api.github.com/repos/jimporter/lockbox-extension/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jimporter/lockbox-extension/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jimporter/lockbox-extension/teams","hooks_url":"https://api.github.com/repos/jimporter/lockbox-extension/hooks","issue_events_url":"https://api.github.com/repos/jimporter/lockbox-extension/issues/events{/number}","events_url":"https://api.github.com/repos/jimporter/lockbox-extension/events","assignees_url":"https://api.github.com/repos/jimporter/lockbox-extension/assignees{/user}","branches_url":"https://api.github.com/repos/jimporter/lockbox-extension/branches{/branch}","tags_url":"https://api.github.com/repos/jimporter/lockbox-extension/tags","blobs_url":"https://api.github.com/repos/jimporter/lockbox-extension/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jimporter/lockbox-extension/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jimporter/lockbox-extension/git/refs{/sha}","trees_url":"https://api.github.com/repos/jimporter/lockbox-extension/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jimporter/lockbox-extension/statuses/{sha}","languages_url":"https://api.github.com/repos/jimporter/lockbox-extension/languages","stargazers_url":"https://api.github.com/repos/jimporter/lockbox-extension/stargazers","contributors_url":"https://api.github.com/repos/jimporter/lockbox-extension/contributors","subscribers_url":"https://api.github.com/repos/jimporter/lockbox-extension/subscribers","subscription_url":"https://api.github.com/repos/jimporter/lockbox-extension/subscription","commits_url":"https://api.github.com/repos/jimporter/lockbox-extension/commits{/sha}","git_commits_url":"https://api.github.com/repos/jimporter/lockbox-extension/git/commits{/sha}","comments_url":"https://api.github.com/repos/jimporter/lockbox-extension/comments{/number}","issue_comment_url":"https://api.github.com/repos/jimporter/lockbox-extension/issues/comments{/number}","contents_url":"https://api.github.com/repos/jimporter/lockbox-extension/contents/{+path}","compare_url":"https://api.github.com/repos/jimporter/lockbox-extension/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jimporter/lockbox-extension/merges","archive_url":"https://api.github.com/repos/jimporter/lockbox-extension/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jimporter/lockbox-extension/downloads","issues_url":"https://api.github.com/repos/jimporter/lockbox-extension/issues{/number}","pulls_url":"https://api.github.com/repos/jimporter/lockbox-extension/pulls{/number}","milestones_url":"https://api.github.com/repos/jimporter/lockbox-extension/milestones{/number}","notifications_url":"https://api.github.com/repos/jimporter/lockbox-extension/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jimporter/lockbox-extension/labels{/name}","releases_url":"https://api.github.com/repos/jimporter/lockbox-extension/releases{/id}","deployments_url":"https://api.github.com/repos/jimporter/lockbox-extension/deployments","created_at":"2017-07-10T19:50:25Z","updated_at":"2018-03-15T17:59:22Z","pushed_at":"2018-03-16T03:04:18Z","git_url":"git://github.com/jimporter/lockbox-extension.git","ssh_url":"git@github.com:jimporter/lockbox-extension.git","clone_url":"https://github.com/jimporter/lockbox-extension.git","svn_url":"https://github.com/jimporter/lockbox-extension","homepage":null,"size":3151,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-lockbox:master","ref":"master","sha":"7965f4872b872ba01bb0d413a460976e513edece","user":{"login":"mozilla-lockbox","id":29802027,"avatar_url":"https://avatars0.githubusercontent.com/u/29802027?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla-lockbox","html_url":"https://github.com/mozilla-lockbox","followers_url":"https://api.github.com/users/mozilla-lockbox/followers","following_url":"https://api.github.com/users/mozilla-lockbox/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-lockbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-lockbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-lockbox/subscriptions","organizations_url":"https://api.github.com/users/mozilla-lockbox/orgs","repos_url":"https://api.github.com/users/mozilla-lockbox/repos","events_url":"https://api.github.com/users/mozilla-lockbox/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-lockbox/received_events","type":"Organization","site_admin":false},"repo":{"id":96805732,"name":"lockbox-extension","full_name":"mozilla-lockbox/lockbox-extension","owner":{"login":"mozilla-lockbox","id":29802027,"avatar_url":"https://avatars0.githubusercontent.com/u/29802027?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla-lockbox","html_url":"https://github.com/mozilla-lockbox","followers_url":"https://api.github.com/users/mozilla-lockbox/followers","following_url":"https://api.github.com/users/mozilla-lockbox/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-lockbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-lockbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-lockbox/subscriptions","organizations_url":"https://api.github.com/users/mozilla-lockbox/orgs","repos_url":"https://api.github.com/users/mozilla-lockbox/repos","events_url":"https://api.github.com/users/mozilla-lockbox/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-lockbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-lockbox/lockbox-extension","description":"Lockbox extension for Firefox","fork":false,"url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension","forks_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/forks","keys_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/teams","hooks_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/hooks","issue_events_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/events","assignees_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/tags","blobs_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/languages","stargazers_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/stargazers","contributors_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/contributors","subscribers_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/subscribers","subscription_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/subscription","commits_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/merges","archive_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/downloads","issues_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/deployments","created_at":"2017-07-10T17:51:30Z","updated_at":"2018-03-16T13:08:46Z","pushed_at":"2018-03-16T03:05:53Z","git_url":"git://github.com/mozilla-lockbox/lockbox-extension.git","ssh_url":"git@github.com:mozilla-lockbox/lockbox-extension.git","clone_url":"https://github.com/mozilla-lockbox/lockbox-extension.git","svn_url":"https://github.com/mozilla-lockbox/lockbox-extension","homepage":"https://mozilla-lockbox.github.io/lockbox-extension/","size":3573,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":21,"mirror_url":null,"archived":false,"open_issues_count":162,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":21,"open_issues":162,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660"},"html":{"href":"https://github.com/mozilla-lockbox/lockbox-extension/pull/660"},"issue":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues/660"},"comments":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/issues/660/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/pulls/660/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-lockbox/lockbox-extension/statuses/5ec79fd58e4c43de89e0b172dc3759ccba6de7ac"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jimporter"}}