Skip to content

Commit

Permalink
Merge pull request #611 from nextcloud-libraries/fix/imagePath-doc
Browse files Browse the repository at this point in the history
fix: `imagePath` always adds `.svg` if no extension is set on the file name
  • Loading branch information
susnux committed Apr 21, 2024
2 parents ef11cf3 + d9f41e3 commit 28067a5
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 28067a5

Please sign in to comment.