diff --git a/.circleci/config.yml b/.circleci/config.yml index 9089d418d7..ba1668148f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,10 +26,10 @@ jobs: - checkout - restore_cache: keys: - - dep-bundle-17-{{ checksum "package.json" }} + - dep-bundle-18-{{ checksum "package.json" }} - run: npm install - save_cache: - key: dep-bundle-17-{{ checksum "package.json" }} + key: dep-bundle-18-{{ checksum "package.json" }} paths: - ~/repo/node_modules - run: npm run lint && npm run test && npm run downloadsolc && npm run make-mock-compiler && npm run build @@ -46,10 +46,10 @@ jobs: - checkout - restore_cache: keys: - - dep-bundle-12-{{ checksum "package.json" }} + - dep-bundle-13-{{ checksum "package.json" }} - run: npm install - save_cache: - key: dep-bundle-12-{{ checksum "package.json" }} + key: dep-bundle-13-{{ checksum "package.json" }} paths: - ~/repo/node_modules - run: npm run build_debugger diff --git a/src/app.js b/src/app.js index c2676f7b4f..81d7798af3 100644 --- a/src/app.js +++ b/src/app.js @@ -148,6 +148,8 @@ class App { self._components.filesProviders['github'] = new BasicReadOnlyExplorer('github') self._components.filesProviders['gist'] = new NotPersistedExplorer('gist') self._components.filesProviders['ipfs'] = new BasicReadOnlyExplorer('ipfs') + self._components.filesProviders['https'] = new BasicReadOnlyExplorer('https') + self._components.filesProviders['http'] = new BasicReadOnlyExplorer('http') registry.put({api: self._components.filesProviders['localhost'], name: 'fileproviders/localhost'}) registry.put({api: self._components.filesProviders['swarm'], name: 'fileproviders/swarm'}) registry.put({api: self._components.filesProviders['github'], name: 'fileproviders/github'}) diff --git a/src/app/compiler/compiler-imports.js b/src/app/compiler/compiler-imports.js index 562233b169..9be0ea60f4 100644 --- a/src/app/compiler/compiler-imports.js +++ b/src/app/compiler/compiler-imports.js @@ -40,10 +40,7 @@ module.exports = class CompilerImports { return request.get( { - url: 'https://gateway.ipfs.io/' + url, - headers: { - 'User-Agent': 'Remix' - } + url: 'https://gateway.ipfs.io/' + url }, (err, r, data) => { if (err) { @@ -53,9 +50,24 @@ module.exports = class CompilerImports { }) } + handleHttpCall (url, cleanUrl, cb) { + return request.get( + { + url + }, + (err, r, data) => { + if (err) { + return cb(err || 'Unknown transport error') + } + cb(null, data, cleanUrl) + }) + } + handlers () { return [ { type: 'github', match: /^(https?:\/\/)?(www.)?github.com\/([^/]*\/[^/]*)\/(.*)/, handler: (match, cb) => { this.handleGithubCall(match[3], match[4], cb) } }, + { type: 'http', match: /^(http?:\/\/?(.*))$/, handler: (match, cb) => { this.handleHttpCall(match[1], match[2], cb) } }, + { type: 'https', match: /^(https?:\/\/?(.*))$/, handler: (match, cb) => { this.handleHttpCall(match[1], match[2], cb) } }, { type: 'swarm', match: /^(bzz[ri]?:\/\/?(.*))$/, handler: (match, cb) => { this.handleSwarmImport(match[1], match[2], cb) } }, { type: 'ipfs', match: /^(ipfs:\/\/?.+)/, handler: (match, cb) => { this.handleIPFS(match[1], cb) } } ] diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index e990d4a9db..3a59bf4a91 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -58,6 +58,8 @@ function filepanel (localRegistry) { var githubExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['github']) var gistExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['gist']) var configExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['config']) + var httpExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['http']) + var httpsExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['https']) // ----------------- editor panel ---------------------- self._compilerMetadata = new CompilerMetadata( @@ -125,6 +127,8 @@ function filepanel (localRegistry) {