1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-22 23:02:10 +10:00

* first action!

This commit is contained in:
shimataro 2019-09-18 20:30:33 +09:00
parent 8deacc95b1
commit 4e3aad3b7f
No known key found for this signature in database
GPG key ID: BE92C05736911A9D
3750 changed files with 1155519 additions and 0 deletions

View file

@ -0,0 +1,38 @@
module.exports = getPage
const deprecate = require('./deprecate')
const getPageLinks = require('./get-page-links')
const HttpError = require('./http-error')
function getPage (octokit, link, which, headers) {
deprecate(`octokit.get${which.charAt(0).toUpperCase() + which.slice(1)}Page() You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
const url = getPageLinks(link)[which]
if (!url) {
const urlError = new HttpError(`No ${which} page found`, 404)
return Promise.reject(urlError)
}
const requestOptions = {
url,
headers: applyAcceptHeader(link, headers)
}
const promise = octokit.request(requestOptions)
return promise
}
function applyAcceptHeader (res, headers) {
const previous = res.headers && res.headers['x-github-media-type']
if (!previous || (headers && headers.accept)) {
return headers
}
headers = headers || {}
headers.accept = 'application/vnd.' + previous
.replace('; param=', '.')
.replace('; format=', '+')
return headers
}