Skip to content

Commit

Permalink
fix(image-loader): URLs with query params lead to broken filenames (#196
Browse files Browse the repository at this point in the history
)
  • Loading branch information
flore2003 authored and madoBaker committed Sep 21, 2018
1 parent d4132f1 commit d32f351
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/providers/image-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ export class ImageLoader {
return (
this.hashString(url).toString() +
(this.config.fileNameCachedWithExtension
? this.getExtensionFromFileName(url)
? this.getExtensionFromUrl(url)
: '')
);
}
Expand All @@ -711,15 +711,15 @@ export class ImageLoader {
}

/**
* extract extension from filename or url
* Extract extension from filename or url
*
* @param {string} filename
* @param {string} url
* @returns {string}
*/
private getExtensionFromFileName(filename: string): string {
private getExtensionFromUrl(url: string): string {
const urlWitoutParams = url.split(/\#|\?/)[0];
return (
// tslint:disable-next-line
filename.substr((~-filename.lastIndexOf('.') >>> 0) + 1) ||
urlWitoutParams.substr((~-urlWitoutParams.lastIndexOf('.') >>> 0) + 1) ||
this.config.fallbackFileNameCachedExtension
);
}
Expand Down

0 comments on commit d32f351

Please sign in to comment.