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
7fbd47de
Commit
7fbd47de
authored
Jan 05, 2021
by
aniket-engg
Committed by
Aniket
Jan 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
raw github instead of github api
parent
7363f0c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
resolve.ts
libs/remix-url-resolver/src/resolve.ts
+4
-3
No files found.
libs/remix-url-resolver/src/resolve.ts
View file @
7fbd47de
...
...
@@ -42,18 +42,19 @@ export class RemixURLResolver {
let
param
=
'?'
param
+=
this
.
gistAccessToken
?
'access_token='
+
this
.
gistAccessToken
:
''
const
regex
=
filePath
.
match
(
/blob
\/([^/]
+
)\/(
.*
)
/
)
let
reference
=
'master'
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
]
reference
=
regex
[
1
]
param
+=
'&ref='
+
reference
filePath
=
filePath
.
replace
(
`blob/
${
reference
}
/`
,
''
)
}
//eslint-disable-next-line no-useless-catch
try
{
const
req
:
string
=
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
filePath
+
param
const
req
:
string
=
`https://raw.githubusercontent.com/
${
root
}
/
${
reference
}
/
${
filePath
}
`
const
response
:
AxiosResponse
=
await
axios
.
get
(
req
)
return
{
content
:
Buffer
.
from
(
response
.
data
.
content
,
'base64'
).
toString
()
,
cleanUrl
:
root
+
'/'
+
filePath
}
return
{
content
:
response
.
data
,
cleanUrl
:
root
+
'/'
+
filePath
}
}
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