Skip to content

Commit

Permalink
fix: imagePath always adds .svg if no extension is set on the fil…
Browse files Browse the repository at this point in the history
…e name

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Apr 21, 2024
1 parent e4d7a25 commit d9f41e3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,16 @@ export const generateUrl = (url: string, params?: object, options?: UrlOptions)

/**
* Get the path with webroot to an image file
* if no extension is given for the image, it will automatically decide
* between .png and .svg based on what the browser supports
* if no extension is given for the image, it will automatically add .svg
*
* @param {string} app the app id to which the image belongs
* @param {string} file the name of the image file
* @return {string}
*/
export const imagePath = (app: string, file: string) => {
if (file.indexOf('.') === -1) {
if (!file.includes('.')) {
// if no extension is given, use svg
return generateFilePath(app, 'img', file + '.svg')
return generateFilePath(app, 'img', `${file}.svg`)
}

return generateFilePath(app, 'img', file)
Expand Down

0 comments on commit d9f41e3

Please sign in to comment.