Merge pull request #1887 from ethereum/githubimport

improving github import
pull/3094/head
yann300 6 years ago committed by GitHub
commit dd6e799469
  1. 14
      src/app/compiler/compiler-imports.js
  2. 2
      src/app/ui/styles/modal-dialog-custom-styles.js

@ -11,10 +11,20 @@ module.exports = class CompilerImports {
}
handleGithubCall (root, path, cb) {
var accessToken = this.githubAccessToken() ? '?access_token=' + this.githubAccessToken() : ''
let param = '?'
param += this.githubAccessToken() ? 'access_token=' + this.githubAccessToken() : ''
const regex = path.match(/blob\/([^/]+)\/(.*)/)
if (regex) {
// if we have /blob/master/+path we extract the branch name "master" and add it as a parameter to the github api
// the ref can be branch name, tag, commit id
const reference = regex[1]
param += 'ref=' + reference
path = path.replace(`blob/${reference}/`, '')
}
return request.get(
{
url: 'https://api.github.com/repos/' + root + '/contents/' + path + accessToken,
url: 'https://api.github.com/repos/' + root + '/contents/' + path + param,
json: true
},
(err, r, data) => {

@ -2,7 +2,7 @@ var csjs = require('csjs-inject')
var css = csjs`
.prompt_text {
width: 300px;
width: 100%;
}
`

Loading…
Cancel
Save