From c4b21f0fb097291b18ea515b4f0a3a55cf78cb6b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 4 Dec 2019 10:10:38 +0100 Subject: [PATCH] MOBILE-3164 core: Fix file ID calculation with tokenpluginfile --- src/providers/filepool.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/providers/filepool.ts b/src/providers/filepool.ts index db8b0f9ea..b025fbbc0 100644 --- a/src/providers/filepool.ts +++ b/src/providers/filepool.ts @@ -1411,16 +1411,19 @@ export class CoreFilepoolProvider { * @return The file ID. */ protected getFileIdByUrl(fileUrl: string): string { - let url = this.removeRevisionFromUrl(fileUrl), + let url = fileUrl, filename; - // Decode URL. - url = this.textUtils.decodeHTML(this.textUtils.decodeURIComponent(url)); - // If site supports it, since 3.8 we use tokenpluginfile instead of pluginfile. // For compatibility with files already downloaded, we need to use pluginfile to calculate the file ID. url = url.replace(/\/tokenpluginfile\.php\/[^\/]+\//, '/webservice/pluginfile.php/'); + // Remove the revision number from the URL so updates on the file aren't detected as a different file. + url = this.removeRevisionFromUrl(url); + + // Decode URL. + url = this.textUtils.decodeHTML(this.textUtils.decodeURIComponent(url)); + if (url.indexOf('/webservice/pluginfile') !== -1) { // Remove attributes that do not matter. this.urlAttributes.forEach((regex) => {