From 80e6ef2e3bb50bc615e2deed1dbd7d98c89cc2bb Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 5 Oct 2019 22:20:31 +0900 Subject: [PATCH] add a reverse mapping for url / path --- src/app/files/fileProvider.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/files/fileProvider.js b/src/app/files/fileProvider.js index 6695a906f8..3907473cce 100644 --- a/src/app/files/fileProvider.js +++ b/src/app/files/fileProvider.js @@ -17,10 +17,13 @@ class FileProvider { addNormalizedName (path, url) { this.providerExternalsStorage.set(this.type + '/' + path, url) + this.providerExternalsStorage.set('reverse-' + url, this.type + '/' + path) } removeNormalizedName (path) { + const value = this.providerExternalsStorage.get(path) this.providerExternalsStorage.remove(path) + this.providerExternalsStorage.remove('reverse-' + value) } normalizedNameExists (path) { @@ -31,6 +34,10 @@ class FileProvider { return this.providerExternalsStorage.get(path) } + getPathFromUrl (url) { + return this.providerExternalsStorage.get('reverse-' + url) + } + isExternalFolder (path) { return this.externalFolders.includes(path) } @@ -71,7 +78,7 @@ class FileProvider { get (path, cb) { 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 exists = window.remixFileSystem.existsSync(unprefixedpath) if (!exists) return cb(null, null)