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
abcc5f0c
Commit
abcc5f0c
authored
Aug 24, 2021
by
yann300
Committed by
Aniket
Aug 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix and add getPathFromUrl and getUrlFromPath
parent
d68f7d11
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+21
-7
fileProvider.js
apps/remix-ide/src/app/files/fileProvider.js
+5
-0
No files found.
apps/remix-ide/src/app/files/fileManager.js
View file @
abcc5f0c
...
...
@@ -22,7 +22,7 @@ const profile = {
icon
:
'assets/img/fileManager.webp'
,
permission
:
true
,
version
:
packageJson
.
version
,
methods
:
[
'file'
,
'exists'
,
'open'
,
'writeFile'
,
'readFile'
,
'copyFile'
,
'copyDir'
,
'rename'
,
'mkdir'
,
'readdir'
,
'remove'
,
'getCurrentFile'
,
'getFile'
,
'getFolder'
,
'setFile'
,
'switchFile'
,
'refresh'
,
'getProviderOf'
,
'getProviderByName'
],
methods
:
[
'file'
,
'exists'
,
'open'
,
'writeFile'
,
'readFile'
,
'copyFile'
,
'copyDir'
,
'rename'
,
'mkdir'
,
'readdir'
,
'remove'
,
'getCurrentFile'
,
'getFile'
,
'getFolder'
,
'setFile'
,
'switchFile'
,
'refresh'
,
'getProviderOf'
,
'getProviderByName'
,
'getPathFromUrl'
,
'getUrlFromPath'
],
kind
:
'file-system'
}
const
errorMsg
=
{
...
...
@@ -171,7 +171,7 @@ class FileManager extends Plugin {
try
{
path
=
this
.
limitPluginScope
(
path
)
try
{
path
=
this
.
_resolveFromExternalPath
(
path
).
file
||
path
path
=
this
.
getPathFromUrl
(
path
).
file
}
catch
(
e
)
{
return
console
.
error
(
e
)
}
...
...
@@ -544,13 +544,13 @@ class FileManager extends Plugin {
}
/**
* Try to resolve the given file path
.
* Try to resolve the given file path
(the actual path in the file system)
* e.g if it's specified a github link, npm library, or any external content,
* it returns the actual path where the content can be f
i
nd.
* @param {string} file
path
we are trying to resolve
* it returns the actual path where the content can be f
ou
nd.
* @param {string} file
url
we are trying to resolve
* @returns {{ string, provider }} file path resolved and its provider.
*/
_resolveFromExternalPath
(
file
)
{
getPathFromUrl
(
file
)
{
const
provider
=
this
.
fileProviderOf
(
file
)
if
(
!
provider
)
throw
new
Error
(
`no provider for
${
file
}
`
)
return
{
...
...
@@ -559,6 +559,20 @@ class FileManager extends Plugin {
}
}
/**
* Try to resolve the given file URl. opposite of getPathFromUrl *
* @param {string} file path we are trying to resolve
* @returns {{ string, provider }} file url resolved and its provider.
*/
getUrlFromPath
(
file
)
{
const
provider
=
this
.
fileProviderOf
(
file
)
if
(
!
provider
)
throw
new
Error
(
`no provider for
${
file
}
`
)
return
{
file
:
provider
.
getUrlFromPath
(
file
)
||
file
,
// in case an external URL is given as input, we resolve it to the right internal path
provider
}
}
removeTabsOf
(
provider
)
{
for
(
var
tab
in
this
.
openedFiles
)
{
if
(
this
.
fileProviderOf
(
tab
).
type
===
provider
.
type
)
{
...
...
@@ -592,7 +606,7 @@ class FileManager extends Plugin {
this
.
saveCurrentFile
()
let
resolved
try
{
resolved
=
this
.
_resolveFromExternalPath
(
file
)
resolved
=
this
.
getPathFromUrl
(
file
)
file
=
resolved
.
file
}
catch
(
e
)
{
return
console
.
error
(
e
)
...
...
apps/remix-ide/src/app/files/fileProvider.js
View file @
abcc5f0c
...
...
@@ -39,6 +39,11 @@ class FileProvider {
return
this
.
providerExternalsStorage
.
get
(
this
.
reverseKey
+
url
)
}
getUrlFromPath
(
path
)
{
if
(
!
path
.
startsWith
(
this
.
type
))
path
=
this
.
type
+
'/'
+
path
return
this
.
providerExternalsStorage
.
get
(
path
)
}
isExternalFolder
(
path
)
{
return
this
.
externalFolders
.
includes
(
path
)
}
...
...
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