Skip to content

Commit 28067a5

Browse files
authored
Merge pull request #611 from nextcloud-libraries/fix/imagePath-doc
fix: `imagePath` always adds `.svg` if no extension is set on the file name
2 parents ef11cf3 + d9f41e3 commit 28067a5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/index.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,16 @@ export const generateUrl = (url: string, params?: object, options?: UrlOptions)
137137

138138
/**
139139
* Get the path with webroot to an image file
140-
* if no extension is given for the image, it will automatically decide
141-
* between .png and .svg based on what the browser supports
140+
* if no extension is given for the image, it will automatically add .svg
142141
*
143142
* @param {string} app the app id to which the image belongs
144143
* @param {string} file the name of the image file
145144
* @return {string}
146145
*/
147146
export const imagePath = (app: string, file: string) => {
148-
if (file.indexOf('.') === -1) {
147+
if (!file.includes('.')) {
149148
// if no extension is given, use svg
150-
return generateFilePath(app, 'img', file + '.svg')
149+
return generateFilePath(app, 'img', `${file}.svg`)
151150
}
152151

153152
return generateFilePath(app, 'img', file)

0 commit comments

Comments
 (0)