update resolver

pull/5370/head
filip mertens 3 years ago
parent 3525f0b92f
commit 52fd10db50
  1. 24
      apps/remix-ide-e2e/src/tests/importFromGithub.test.ts
  2. 12
      libs/remix-url-resolver/src/resolve.ts
  3. 2
      package.json

@ -4,7 +4,8 @@ import init from '../helpers/init'
const testData = {
validURL: 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol',
invalidURL: 'https://github.com/Oppelin/Roles.sol'
invalidURL: 'https://github.com/Oppelin/Roles.sol',
JSON: 'https://github.com/ethereum/remix-project/blob/master/package.json'
}
module.exports = {
@ -57,6 +58,27 @@ module.exports = {
.scrollAndClick('[data-id="homeTab-modal-footer-ok-react"]')
.openFile('github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol')
.waitForElementVisible("div[title='default_workspace/github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol'")
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('library Roles {') !== -1, 'content does contain "library Roles {"')
})
},
'Import JSON From Github For Valid URL': function (browser: NightwatchBrowser) {
browser
.click('div[title="home"]')
.scrollAndClick('*[data-id="landingPageImportFromGitHubButton"]')
.waitForElementVisible('*[data-id="homeTabModalDialogCustomPromptText"]')
.clearValue('*[data-id="homeTabModalDialogCustomPromptText"]')
.execute(() => {
(document.querySelector('input[data-id="homeTabModalDialogCustomPromptText"]') as any).focus()
}, [], () => {})
.setValue('input[data-id="homeTabModalDialogCustomPromptText"]', testData.JSON)
.waitForElementVisible('*[data-id="homeTab-modal-footer-ok-react"]')
.scrollAndClick('[data-id="homeTab-modal-footer-ok-react"]')
.openFile('github/ethereum/remix-project/package.json')
.waitForElementVisible("div[title='default_workspace/github/ethereum/remix-project/package.json'")
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('"name": "remix-project",') !== -1, 'content does contain "name": "remix-project"')
})
.end()
}
}

@ -55,7 +55,7 @@ export class RemixURLResolver {
// eslint-disable-next-line no-useless-catch
try {
const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}`
const response: AxiosResponse = await axios.get(req)
const response: AxiosResponse = await axios.get(req, { transformResponse: [] })
return { content: response.data, cleanUrl: root + '/' + filePath }
} catch (e) {
throw e
@ -70,7 +70,7 @@ export class RemixURLResolver {
async handleHttp (url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch
try {
const response: AxiosResponse = await axios.get(url)
const response: AxiosResponse = await axios.get(url, { transformResponse: [] })
return { content: response.data, cleanUrl }
} catch (e) {
throw e
@ -85,7 +85,7 @@ export class RemixURLResolver {
async handleHttps (url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch
try {
const response: AxiosResponse = await axios.get(url)
const response: AxiosResponse = await axios.get(url, { transformResponse: [] })
return { content: response.data, cleanUrl }
} catch (e) {
throw e
@ -97,7 +97,7 @@ export class RemixURLResolver {
try {
const bzz = new Bzz({ url: this.protocol + '//swarm-gateways.net' })
const url = bzz.getDownloadURL(cleanUrl, { mode: 'raw' })
const response: AxiosResponse = await axios.get(url)
const response: AxiosResponse = await axios.get(url, { transformResponse: [] })
return { content: response.data, cleanUrl }
} catch (e) {
throw e
@ -116,7 +116,7 @@ export class RemixURLResolver {
const req = 'https://ipfs.remixproject.org/' + url
// If you don't find greeter.sol on ipfs gateway use local
// const req = 'http://localhost:8080/' + url
const response: AxiosResponse = await axios.get(req)
const response: AxiosResponse = await axios.get(req, { transformResponse: [] })
return { content: response.data, cleanUrl: url.replace('ipfs/', '') }
} catch (e) {
throw e
@ -131,7 +131,7 @@ export class RemixURLResolver {
// eslint-disable-next-line no-useless-catch
try {
const req = 'https://unpkg.com/' + url
const response: AxiosResponse = await axios.get(req)
const response: AxiosResponse = await axios.get(req, { transformResponse: [] })
return { content: response.data, cleanUrl: url }
} catch (e) {
throw e

@ -161,7 +161,7 @@
"@remixproject/plugin-ws": "^0.3.28",
"ansi-gray": "^0.1.1",
"async": "^2.6.2",
"axios": ">=0.21.1",
"axios": ">=0.26.0",
"brace": "^0.8.0",
"change-case": "^4.1.1",
"chokidar": "^2.1.8",

Loading…
Cancel
Save