From 6593f6f3ce6df90e813ff9a272d27ec8ba246613 Mon Sep 17 00:00:00 2001 From: Chris Roberson Date: Thu, 10 Mar 2016 09:52:15 -0500 Subject: [PATCH 1/3] Use `requestAllPages` for search endpoints --- README.md | 10 +++++++--- package.json | 2 +- src/github.js | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 045a66bf..290809bc 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,12 @@ bower install github-api [![Sauce Test Status](https://saucelabs.com/browser-matrix/githubjs.svg)](https://saucelabs.com/u/githubjs) -**Note**: Starting from version 0.10.8, Github.js supports **Internet Explorer 9**. However, the underlying +**Note**: Starting from version 0.10.8, Github.js supports **Internet Explorer 9**. However, the underlying methodology used under the hood to perform CORS requests (the `XDomainRequest` object), [has limitations](http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx). -In particular, requests must be targeted to the same scheme as the hosting page. This means that if a page is at +In particular, requests must be targeted to the same scheme as the hosting page. This means that if a page is at http://example.com, your target URL must also begin with HTTP. Similarly, if your page is at https://example.com, then -your target URL must also begin with HTTPS. For this reason, if your requests are sent to the GitHub API (the default), +your target URL must also begin with HTTPS. For this reason, if your requests are sent to the GitHub API (the default), which are served via HTTPS, your page must use HTTPS too. ## GitHub Tools @@ -491,6 +491,10 @@ rateLimit.getRateLimit(function (err, rateInfo) {}); ## Change Log +### 0.12.0 + +Change all Search endpoints to use _requestAllPages. This is technically a breaking change because callers will need to flatten the results now + ### 0.10.X Create and delete repositories diff --git a/package.json b/package.json index 15501508..9e291708 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-api", - "version": "0.11.2", + "version": "0.12.0", "description": "A higher-level wrapper around the Github API.", "main": "src/github.js", "dependencies": { diff --git a/src/github.js b/src/github.js index dd4da081..cb5d0c69 100644 --- a/src/github.js +++ b/src/github.js @@ -1074,20 +1074,30 @@ var path = '/search/'; var query = '?q=' + options.query; + function getQueryFromOptions(options) { + var localQuery = query.slice(0); + for (var key in options) { + if (options.hasOwnProperty(key)) { + localQuery.push(encodeURIComponent(key) + '=' + encodeURIComponent(options[key])); + } + } + return localQuery.join('&'); + } + this.repositories = function (options, cb) { - _request('GET', path + 'repositories' + query, options, cb); + _requestAllPages(path + 'repositories?' + getQueryFromOptions(options), cb); }; this.code = function (options, cb) { - _request('GET', path + 'code' + query, options, cb); + _requestAllPages(path + 'code?' + getQueryFromOptions(options), cb); }; this.issues = function (options, cb) { - _request('GET', path + 'issues' + query, options, cb); + _requestAllPages(path + 'issues?' + getQueryFromOptions(options), cb); }; this.users = function (options, cb) { - _request('GET', path + 'users' + query, options, cb); + _requestAllPages(path + 'users?' + getQueryFromOptions(options), cb); }; }; From ea9d69a20e381b8324fd244c6645c52859a443b0 Mon Sep 17 00:00:00 2001 From: Chris Roberson Date: Thu, 10 Mar 2016 11:29:34 -0500 Subject: [PATCH 2/3] Initialize the query object as an array instead of string --- src/github.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github.js b/src/github.js index cb5d0c69..762cd3bc 100644 --- a/src/github.js +++ b/src/github.js @@ -1072,7 +1072,7 @@ Github.Search = function (options) { var path = '/search/'; - var query = '?q=' + options.query; + var query = ['q=' + options.query]; function getQueryFromOptions(options) { var localQuery = query.slice(0); From 85482ce210bbfac21ceae15d6ea306bae71e9f07 Mon Sep 17 00:00:00 2001 From: Chris Roberson Date: Thu, 31 Mar 2016 09:51:21 -0400 Subject: [PATCH 3/3] Revert changeling and package.json changes --- README.md | 10 +++------- package.json | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 290809bc..045a66bf 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,12 @@ bower install github-api [![Sauce Test Status](https://saucelabs.com/browser-matrix/githubjs.svg)](https://saucelabs.com/u/githubjs) -**Note**: Starting from version 0.10.8, Github.js supports **Internet Explorer 9**. However, the underlying +**Note**: Starting from version 0.10.8, Github.js supports **Internet Explorer 9**. However, the underlying methodology used under the hood to perform CORS requests (the `XDomainRequest` object), [has limitations](http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx). -In particular, requests must be targeted to the same scheme as the hosting page. This means that if a page is at +In particular, requests must be targeted to the same scheme as the hosting page. This means that if a page is at http://example.com, your target URL must also begin with HTTP. Similarly, if your page is at https://example.com, then -your target URL must also begin with HTTPS. For this reason, if your requests are sent to the GitHub API (the default), +your target URL must also begin with HTTPS. For this reason, if your requests are sent to the GitHub API (the default), which are served via HTTPS, your page must use HTTPS too. ## GitHub Tools @@ -491,10 +491,6 @@ rateLimit.getRateLimit(function (err, rateInfo) {}); ## Change Log -### 0.12.0 - -Change all Search endpoints to use _requestAllPages. This is technically a breaking change because callers will need to flatten the results now - ### 0.10.X Create and delete repositories diff --git a/package.json b/package.json index 9e291708..15501508 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-api", - "version": "0.12.0", + "version": "0.11.2", "description": "A higher-level wrapper around the Github API.", "main": "src/github.js", "dependencies": {