{"action":"created","comment":{"url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/comments/32311630","id":32311630,"diff_hunk":"@@ -206,4 +206,142 @@ describe('Router instances', function () {\n     });\n   });\n \n+\n+  describe('Matching algorithm', function() {\n+    describe('match()', function() {\n+      var mw = function() {};\n+\n+      it('should match universal registrations (*)', function() {\n+        router.get('*', mw);\n+\n+        expect(router.match('get', '/')).to.deep.equal([mw]);\n+        expect(router.match('get', '/foo/bar')).to.deep.equal([mw]);\n+      });\n+\n+      it('should match all universal registrations (*) in order', function() {\n+        var mw2 = function () {},\n+            mw3 = function () {};\n+\n+        router.get('*', mw);\n+        router.get('/foo/bar', mw2);\n+        router.get('*', mw3);\n+\n+        expect(router.match('get', '/')).to.deep.equal([mw, mw3]);\n+        expect(router.match('get', '/foo/bar')).to.deep.equal([mw, mw2, mw3]);\n+      });\n+\n+      it('trailing placeholders (/foo/* etc.) should match arbitrary prefixes', function() {\n+        var mw2 = function () {};\n+\n+        router.get('/foo/*', mw);\n+        router.get('/foo/bar/*', mw2);\n+\n+        expect(router.match('get', '/')).to.be.empty;\n+        expect(router.match('get', '/foo')).to.be.empty;\n+        expect(router.match('get', '/foo/')).to.deep.equal([mw]);\n+        expect(router.match('get', '/foo/bar')).to.deep.equal([mw]);\n+        expect(router.match('get', '/foo/bar/baz')).to.deep.equal([mw, mw2]);\n+      });\n+\n+      it('infix placeholders (/foo/*/bar etc.) should match arbitrary path chunks', function() {\n+        var mw2 = function () {};\n+\n+        router.get('/foo*bar', mw);\n+        router.get('/foo/*/bar', mw2);\n+\n+        expect(router.match('get', '/')).to.be.empty;\n+        expect(router.match('get', '/foo')).to.be.empty;\n+        expect(router.match('get', '/foo/bar')).to.deep.equal([mw]);\n+        expect(router.match('get', '/foo/doh/bar')).to.deep.equal([mw, mw2]);\n+        expect(router.match('get', '/foobar/baz')).to.deep.equal([mw]);\n+      });\n+\n+      it('multiple placeholders (/foo/*/bar/* etc) should be allowed', function() {\n+        var mw2 = function () {},\n+            mw3 = function () {};\n+\n+        router.get('/pre/*/fix/*', mw);\n+        router.get('*/suf/*/fix', mw2);\n+        router.get('*inner*', mw3);\n+\n+        expect(router.match('get', '/')).to.be.empty;\n+        expect(router.match('get', '/pre/123/fix/')).to.deep.equal([mw]);\n+        expect(router.match('get', '/pre/123/fix/456')).to.deep.equal([mw]);\n+        expect(router.match('get', '/pre/123/')).to.be.empty;\n+\n+        expect(router.match('get', '/matched/suf/123/fix')).to.deep.equal([mw2]);\n+        expect(router.match('get', '/any/other/suf/123/456/fix')).to.deep.equal([mw2]);\n+        expect(router.match('get', '/suf/nopre/fix')).to.deep.equal([mw2]);\n+        expect(router.match('get', '/fix')).to.be.empty;\n+\n+        expect(router.match('get', '/pre/suf/fix/')).to.deep.equal([mw]);\n+\n+        expect(router.match('get', '/inner')).to.deep.equal([mw3]);\n+        expect(router.match('get', '/beginners')).to.deep.equal([mw3]);\n+        expect(router.match('get', '/pre/inner/fix/')).to.deep.equal([mw, mw3]);\n+        expect(router.match('get', '/inner/suf/other/fix/')).to.deep.equal([mw2, mw3]);\n+\n+        expect(router.match('get', '/pre/123/fix/inner/suf/456/fix/')).to.deep.equal([mw, mw2, mw3]);\n+        expect(router.match('get', '/pre/suf/inner/fix/')).to.deep.equal([mw, mw2, mw3]);\n+      });\n+\n+      it('named placeholders (:foo) should match similar to anonymous ones', function() {\n+        router.get('/:foo', mw);\n+        expect(router.match('get', '/foo')).to.deep.equal([mw]);\n+        expect(router.match('get', '/foo/bar')).to.deep.equal([mw]);\n+      });\n+\n+      it('named placeholders (:foo) must match at least one character (no empty matches allowed)', function() {\n+        router.get('/:foo', mw);\n+        expect(router.match('get', '/')).to.be.empty;\n+        expect(router.match('get', '/foo/bar')).to.deep.equal([mw]);\n+      });\n+\n+      it('placeholder crowding for anonymous placeholder (**) should be treated same as a single placeholder', function() {\n+        var mw2 = function () {};\n+\n+        expect(function() { router.get('/f**bar', mw); }).to.not.throw;\n+        router.get('/f*bar', mw2);\n+\n+        expect(router.match('get', '/foo')).to.deep.equal(router.match('get', '/foo'));\n+        expect(router.match('get', '/foobar')).to.deep.equal(router.match('get', '/foobar'));\n+        expect(router.match('get', '/foobabarbar')).to.deep.equal(router.match('get', '/foobabarbar'));\n+        expect(router.match('get', '/foo/bar/baz')).to.deep.equal(router.match('get', '/foo/bar/baz'));\n+        expect(router.match('get', '/foo/doh/bar')).to.deep.equal(router.match('get', '/foo/doh/bar'));\n+      });\n+\n+      it('placeholder crowding for named placeholder (:foo:bar) should throw', function() {\n+        expect(function () { router.get('/foo/:bar:baz', mw); }).to.throw(Error, 'Invalid usage of named placeholders');\n+      });\n+","path":"lib/spec/router.sw-spec.js","position":111,"original_position":111,"commit_id":"e4c99265196c5a5b4d4d31528be19bda614d3118","original_commit_id":"e4c99265196c5a5b4d4d31528be19bda614d3118","user":{"login":"lodr","id":757942,"avatar_url":"https://avatars.githubusercontent.com/u/757942?v=3","gravatar_id":"","url":"https://api.github.com/users/lodr","html_url":"https://github.com/lodr","followers_url":"https://api.github.com/users/lodr/followers","following_url":"https://api.github.com/users/lodr/following{/other_user}","gists_url":"https://api.github.com/users/lodr/gists{/gist_id}","starred_url":"https://api.github.com/users/lodr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lodr/subscriptions","organizations_url":"https://api.github.com/users/lodr/orgs","repos_url":"https://api.github.com/users/lodr/repos","events_url":"https://api.github.com/users/lodr/events{/privacy}","received_events_url":"https://api.github.com/users/lodr/received_events","type":"User","site_admin":false},"body":"Add a couple of more tests to test _triple_ crowding: `***` and `:foor:bar:foo`.","created_at":"2015-06-12T12:35:44Z","updated_at":"2015-06-12T12:35:44Z","html_url":"https://github.com/gaia-components/serviceworkerware/pull/21#discussion_r32311630","pull_request_url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/comments/32311630"},"html":{"href":"https://github.com/gaia-components/serviceworkerware/pull/21#discussion_r32311630"},"pull_request":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21","id":37125524,"html_url":"https://github.com/gaia-components/serviceworkerware/pull/21","diff_url":"https://github.com/gaia-components/serviceworkerware/pull/21.diff","patch_url":"https://github.com/gaia-components/serviceworkerware/pull/21.patch","issue_url":"https://api.github.com/repos/gaia-components/serviceworkerware/issues/21","number":21,"state":"open","locked":false,"title":" [ServiceWorkers] Create a better algoritm to match urls (#1165858)","user":{"login":"flaki","id":2089432,"avatar_url":"https://avatars.githubusercontent.com/u/2089432?v=3","gravatar_id":"","url":"https://api.github.com/users/flaki","html_url":"https://github.com/flaki","followers_url":"https://api.github.com/users/flaki/followers","following_url":"https://api.github.com/users/flaki/following{/other_user}","gists_url":"https://api.github.com/users/flaki/gists{/gist_id}","starred_url":"https://api.github.com/users/flaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flaki/subscriptions","organizations_url":"https://api.github.com/users/flaki/orgs","repos_url":"https://api.github.com/users/flaki/repos","events_url":"https://api.github.com/users/flaki/events{/privacy}","received_events_url":"https://api.github.com/users/flaki/received_events","type":"User","site_admin":false},"body":"Preliminary implementation of the new route matching algorithm + tests:\r\n* I have added basic support for the `*` token which matches arbitrary-length substrings (and is basically translated to `(.*?)`)\r\n* at the moment the `:foobar123`-style tokens are currently simple aliases for the `*` token, their role might later be more refined (arbitrary matching rules, or more restricted translation like `(\\w+)`\r\n* I have removed backward compatibility with paths specified with RegExp-syntax\r\n\r\nThere are two disabled tests, until we decide what to do in the situations:\r\n* Placeholder-crowding (`**`, `:foo:bar` etc.)\r\n* Invalid characters/syntax in path string","created_at":"2015-06-08T06:40:46Z","updated_at":"2015-06-12T12:35:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"33986bd8ea2ef86b6e3bfda2f6c4776472af0207","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21/commits","review_comments_url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21/comments","review_comment_url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gaia-components/serviceworkerware/issues/21/comments","statuses_url":"https://api.github.com/repos/gaia-components/serviceworkerware/statuses/e4c99265196c5a5b4d4d31528be19bda614d3118","head":{"label":"flaki:bug-1165858","ref":"bug-1165858","sha":"e4c99265196c5a5b4d4d31528be19bda614d3118","user":{"login":"flaki","id":2089432,"avatar_url":"https://avatars.githubusercontent.com/u/2089432?v=3","gravatar_id":"","url":"https://api.github.com/users/flaki","html_url":"https://github.com/flaki","followers_url":"https://api.github.com/users/flaki/followers","following_url":"https://api.github.com/users/flaki/following{/other_user}","gists_url":"https://api.github.com/users/flaki/gists{/gist_id}","starred_url":"https://api.github.com/users/flaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flaki/subscriptions","organizations_url":"https://api.github.com/users/flaki/orgs","repos_url":"https://api.github.com/users/flaki/repos","events_url":"https://api.github.com/users/flaki/events{/privacy}","received_events_url":"https://api.github.com/users/flaki/received_events","type":"User","site_admin":false},"repo":{"id":36195346,"name":"serviceworkerware","full_name":"flaki/serviceworkerware","owner":{"login":"flaki","id":2089432,"avatar_url":"https://avatars.githubusercontent.com/u/2089432?v=3","gravatar_id":"","url":"https://api.github.com/users/flaki","html_url":"https://github.com/flaki","followers_url":"https://api.github.com/users/flaki/followers","following_url":"https://api.github.com/users/flaki/following{/other_user}","gists_url":"https://api.github.com/users/flaki/gists{/gist_id}","starred_url":"https://api.github.com/users/flaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flaki/subscriptions","organizations_url":"https://api.github.com/users/flaki/orgs","repos_url":"https://api.github.com/users/flaki/repos","events_url":"https://api.github.com/users/flaki/events{/privacy}","received_events_url":"https://api.github.com/users/flaki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/flaki/serviceworkerware","description":"","fork":true,"url":"https://api.github.com/repos/flaki/serviceworkerware","forks_url":"https://api.github.com/repos/flaki/serviceworkerware/forks","keys_url":"https://api.github.com/repos/flaki/serviceworkerware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flaki/serviceworkerware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flaki/serviceworkerware/teams","hooks_url":"https://api.github.com/repos/flaki/serviceworkerware/hooks","issue_events_url":"https://api.github.com/repos/flaki/serviceworkerware/issues/events{/number}","events_url":"https://api.github.com/repos/flaki/serviceworkerware/events","assignees_url":"https://api.github.com/repos/flaki/serviceworkerware/assignees{/user}","branches_url":"https://api.github.com/repos/flaki/serviceworkerware/branches{/branch}","tags_url":"https://api.github.com/repos/flaki/serviceworkerware/tags","blobs_url":"https://api.github.com/repos/flaki/serviceworkerware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flaki/serviceworkerware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flaki/serviceworkerware/git/refs{/sha}","trees_url":"https://api.github.com/repos/flaki/serviceworkerware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flaki/serviceworkerware/statuses/{sha}","languages_url":"https://api.github.com/repos/flaki/serviceworkerware/languages","stargazers_url":"https://api.github.com/repos/flaki/serviceworkerware/stargazers","contributors_url":"https://api.github.com/repos/flaki/serviceworkerware/contributors","subscribers_url":"https://api.github.com/repos/flaki/serviceworkerware/subscribers","subscription_url":"https://api.github.com/repos/flaki/serviceworkerware/subscription","commits_url":"https://api.github.com/repos/flaki/serviceworkerware/commits{/sha}","git_commits_url":"https://api.github.com/repos/flaki/serviceworkerware/git/commits{/sha}","comments_url":"https://api.github.com/repos/flaki/serviceworkerware/comments{/number}","issue_comment_url":"https://api.github.com/repos/flaki/serviceworkerware/issues/comments{/number}","contents_url":"https://api.github.com/repos/flaki/serviceworkerware/contents/{+path}","compare_url":"https://api.github.com/repos/flaki/serviceworkerware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flaki/serviceworkerware/merges","archive_url":"https://api.github.com/repos/flaki/serviceworkerware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flaki/serviceworkerware/downloads","issues_url":"https://api.github.com/repos/flaki/serviceworkerware/issues{/number}","pulls_url":"https://api.github.com/repos/flaki/serviceworkerware/pulls{/number}","milestones_url":"https://api.github.com/repos/flaki/serviceworkerware/milestones{/number}","notifications_url":"https://api.github.com/repos/flaki/serviceworkerware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flaki/serviceworkerware/labels{/name}","releases_url":"https://api.github.com/repos/flaki/serviceworkerware/releases{/id}","created_at":"2015-05-24T21:45:51Z","updated_at":"2015-05-24T21:45:52Z","pushed_at":"2015-06-11T16:10:19Z","git_url":"git://github.com/flaki/serviceworkerware.git","ssh_url":"git@github.com:flaki/serviceworkerware.git","clone_url":"https://github.com/flaki/serviceworkerware.git","svn_url":"https://github.com/flaki/serviceworkerware","homepage":null,"size":183,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"gaia-components:master","ref":"master","sha":"021ac35425d7c13ccbb2309c4d01fd64a92edc0f","user":{"login":"gaia-components","id":7851599,"avatar_url":"https://avatars.githubusercontent.com/u/7851599?v=3","gravatar_id":"","url":"https://api.github.com/users/gaia-components","html_url":"https://github.com/gaia-components","followers_url":"https://api.github.com/users/gaia-components/followers","following_url":"https://api.github.com/users/gaia-components/following{/other_user}","gists_url":"https://api.github.com/users/gaia-components/gists{/gist_id}","starred_url":"https://api.github.com/users/gaia-components/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaia-components/subscriptions","organizations_url":"https://api.github.com/users/gaia-components/orgs","repos_url":"https://api.github.com/users/gaia-components/repos","events_url":"https://api.github.com/users/gaia-components/events{/privacy}","received_events_url":"https://api.github.com/users/gaia-components/received_events","type":"Organization","site_admin":false},"repo":{"id":31429789,"name":"serviceworkerware","full_name":"gaia-components/serviceworkerware","owner":{"login":"gaia-components","id":7851599,"avatar_url":"https://avatars.githubusercontent.com/u/7851599?v=3","gravatar_id":"","url":"https://api.github.com/users/gaia-components","html_url":"https://github.com/gaia-components","followers_url":"https://api.github.com/users/gaia-components/followers","following_url":"https://api.github.com/users/gaia-components/following{/other_user}","gists_url":"https://api.github.com/users/gaia-components/gists{/gist_id}","starred_url":"https://api.github.com/users/gaia-components/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaia-components/subscriptions","organizations_url":"https://api.github.com/users/gaia-components/orgs","repos_url":"https://api.github.com/users/gaia-components/repos","events_url":"https://api.github.com/users/gaia-components/events{/privacy}","received_events_url":"https://api.github.com/users/gaia-components/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gaia-components/serviceworkerware","description":"","fork":false,"url":"https://api.github.com/repos/gaia-components/serviceworkerware","forks_url":"https://api.github.com/repos/gaia-components/serviceworkerware/forks","keys_url":"https://api.github.com/repos/gaia-components/serviceworkerware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gaia-components/serviceworkerware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gaia-components/serviceworkerware/teams","hooks_url":"https://api.github.com/repos/gaia-components/serviceworkerware/hooks","issue_events_url":"https://api.github.com/repos/gaia-components/serviceworkerware/issues/events{/number}","events_url":"https://api.github.com/repos/gaia-components/serviceworkerware/events","assignees_url":"https://api.github.com/repos/gaia-components/serviceworkerware/assignees{/user}","branches_url":"https://api.github.com/repos/gaia-components/serviceworkerware/branches{/branch}","tags_url":"https://api.github.com/repos/gaia-components/serviceworkerware/tags","blobs_url":"https://api.github.com/repos/gaia-components/serviceworkerware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gaia-components/serviceworkerware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gaia-components/serviceworkerware/git/refs{/sha}","trees_url":"https://api.github.com/repos/gaia-components/serviceworkerware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gaia-components/serviceworkerware/statuses/{sha}","languages_url":"https://api.github.com/repos/gaia-components/serviceworkerware/languages","stargazers_url":"https://api.github.com/repos/gaia-components/serviceworkerware/stargazers","contributors_url":"https://api.github.com/repos/gaia-components/serviceworkerware/contributors","subscribers_url":"https://api.github.com/repos/gaia-components/serviceworkerware/subscribers","subscription_url":"https://api.github.com/repos/gaia-components/serviceworkerware/subscription","commits_url":"https://api.github.com/repos/gaia-components/serviceworkerware/commits{/sha}","git_commits_url":"https://api.github.com/repos/gaia-components/serviceworkerware/git/commits{/sha}","comments_url":"https://api.github.com/repos/gaia-components/serviceworkerware/comments{/number}","issue_comment_url":"https://api.github.com/repos/gaia-components/serviceworkerware/issues/comments{/number}","contents_url":"https://api.github.com/repos/gaia-components/serviceworkerware/contents/{+path}","compare_url":"https://api.github.com/repos/gaia-components/serviceworkerware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gaia-components/serviceworkerware/merges","archive_url":"https://api.github.com/repos/gaia-components/serviceworkerware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gaia-components/serviceworkerware/downloads","issues_url":"https://api.github.com/repos/gaia-components/serviceworkerware/issues{/number}","pulls_url":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls{/number}","milestones_url":"https://api.github.com/repos/gaia-components/serviceworkerware/milestones{/number}","notifications_url":"https://api.github.com/repos/gaia-components/serviceworkerware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gaia-components/serviceworkerware/labels{/name}","releases_url":"https://api.github.com/repos/gaia-components/serviceworkerware/releases{/id}","created_at":"2015-02-27T17:04:42Z","updated_at":"2015-05-18T12:17:49Z","pushed_at":"2015-06-12T11:42:46Z","git_url":"git://github.com/gaia-components/serviceworkerware.git","ssh_url":"git@github.com:gaia-components/serviceworkerware.git","clone_url":"https://github.com/gaia-components/serviceworkerware.git","svn_url":"https://github.com/gaia-components/serviceworkerware","homepage":null,"size":646,"stargazers_count":14,"watchers_count":14,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":4,"forks":7,"open_issues":4,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21"},"html":{"href":"https://github.com/gaia-components/serviceworkerware/pull/21"},"issue":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/issues/21"},"comments":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/gaia-components/serviceworkerware/statuses/e4c99265196c5a5b4d4d31528be19bda614d3118"}}}}