Merge pull request #2180 from dpalou/MOBILE-3164

MOBILE-3164 core: Fix file ID calculation with tokenpluginfile
main
Juan Leyva 2019-12-04 10:33:43 +01:00 committed by GitHub
commit 8280e5c4dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -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) => {