Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
edef2892
Commit
edef2892
authored
Dec 22, 2020
by
aniket-engg
Committed by
Aniket
Jan 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handler response type
parent
dfcd03c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
resolve.ts
libs/remix-url-resolver/src/resolve.ts
+12
-7
No files found.
libs/remix-url-resolver/src/resolve.ts
View file @
edef2892
...
...
@@ -16,6 +16,11 @@ interface Handler {
handle
(
match
:
any
):
any
;
}
interface
HandlerResponse
{
content
:
any
;
cleanUrl
:
string
}
export
class
RemixURLResolver
{
private
previouslyHandled
:
PreviouslyHandledImports
gistAccessToken
:
string
...
...
@@ -30,7 +35,7 @@ export class RemixURLResolver {
* @param root The root of the github import statement
* @param filePath path of the file in github
*/
async
handleGithubCall
(
root
:
string
,
filePath
:
string
)
{
async
handleGithubCall
(
root
:
string
,
filePath
:
string
)
:
Promise
<
HandlerResponse
>
{
let
param
=
'?'
param
+=
this
.
gistAccessToken
?
'access_token='
+
this
.
gistAccessToken
:
''
const
regex
=
filePath
.
match
(
/blob
\/([^/]
+
)\/(
.*
)
/
)
...
...
@@ -56,7 +61,7 @@ export class RemixURLResolver {
* @param url The url of the import statement
* @param cleanUrl
*/
async
handleHttp
(
url
:
string
,
cleanUrl
:
string
)
{
async
handleHttp
(
url
:
string
,
cleanUrl
:
string
)
:
Promise
<
HandlerResponse
>
{
//eslint-disable-next-line no-useless-catch
try
{
const
response
:
AxiosResponse
=
await
axios
.
get
(
url
)
...
...
@@ -71,17 +76,17 @@ export class RemixURLResolver {
* @param url The url of the import statement
* @param cleanUrl
*/
async
handleHttps
(
url
:
string
,
cleanUrl
:
string
)
{
async
handleHttps
(
url
:
string
,
cleanUrl
:
string
)
:
Promise
<
HandlerResponse
>
{
//eslint-disable-next-line no-useless-catch
try
{
const
response
:
AxiosResponse
=
await
axios
.
get
(
url
)
return
{
content
:
response
.
data
,
cleanUrl
}
return
{
content
:
response
.
data
,
cleanUrl
}
}
catch
(
e
)
{
throw
e
}
}
handleSwarm
(
url
:
string
,
cleanU
RL
:
string
)
{
handleSwarm
(
url
:
string
,
cleanU
rl
:
string
)
{
return
}
...
...
@@ -89,7 +94,7 @@ export class RemixURLResolver {
* Handle an import statement based on IPFS
* @param url The url of the IPFS import statement
*/
async
handleIPFS
(
url
:
string
)
{
async
handleIPFS
(
url
:
string
)
:
Promise
<
HandlerResponse
>
{
// replace ipfs:// with /ipfs/
url
=
url
.
replace
(
/^ipfs:
\/\/?
/
,
'ipfs/'
)
//eslint-disable-next-line no-useless-catch
...
...
@@ -98,7 +103,7 @@ export class RemixURLResolver {
// 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
)
return
response
.
data
return
{
content
:
response
.
data
,
cleanUrl
:
url
}
}
catch
(
e
)
{
throw
e
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment