Commit 80e6ef2e authored by yann300's avatar yann300

add a reverse mapping for url / path

parent 7d6386c3
...@@ -17,10 +17,13 @@ class FileProvider { ...@@ -17,10 +17,13 @@ class FileProvider {
addNormalizedName (path, url) { addNormalizedName (path, url) {
this.providerExternalsStorage.set(this.type + '/' + path, url) this.providerExternalsStorage.set(this.type + '/' + path, url)
this.providerExternalsStorage.set('reverse-' + url, this.type + '/' + path)
} }
removeNormalizedName (path) { removeNormalizedName (path) {
const value = this.providerExternalsStorage.get(path)
this.providerExternalsStorage.remove(path) this.providerExternalsStorage.remove(path)
this.providerExternalsStorage.remove('reverse-' + value)
} }
normalizedNameExists (path) { normalizedNameExists (path) {
...@@ -31,6 +34,10 @@ class FileProvider { ...@@ -31,6 +34,10 @@ class FileProvider {
return this.providerExternalsStorage.get(path) return this.providerExternalsStorage.get(path)
} }
getPathFromUrl (url) {
return this.providerExternalsStorage.get('reverse-' + url)
}
isExternalFolder (path) { isExternalFolder (path) {
return this.externalFolders.includes(path) return this.externalFolders.includes(path)
} }
...@@ -71,7 +78,7 @@ class FileProvider { ...@@ -71,7 +78,7 @@ class FileProvider {
get (path, cb) { get (path, cb) {
cb = cb || function () {} cb = cb || function () {}
if (this.normalizedNameExists(path)) path = this.getNormalizedName(path) // ensure we actually use the normalized path from here path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath) var exists = window.remixFileSystem.existsSync(unprefixedpath)
if (!exists) return cb(null, null) if (!exists) return cb(null, null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment