Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: imagePath always adds .svg if no extension is set on the file name #611

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading